Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save supaplextor/e292242e2b6748fd8876a4af68048771 to your computer and use it in GitHub Desktop.
Save supaplextor/e292242e2b6748fd8876a4af68048771 to your computer and use it in GitHub Desktop.
Proof Of Concept FastLED with M5Atom
#include <M5StickC.h> // should work with any grove port really. i2c?
#include <FastLED.h> // https://github.com/FastLED/FastLED
/* note, two led strips in use, one cell onboard and the rest on another strip. */
#define NUM_LEDS 20
#define DATA_PIN 32 // large strip
CRGB leds[NUM_LEDS+1];
CRGB dot[0];
uint8_t cell = 0;
uint8_t modes = 0;
bool enable_strip = true;
void wipeStrip();
void setup() {
M5.begin();
Serial.begin(115200);
Serial.println("setup() Starting...");
pinMode(39, INPUT_PULLUP); // aka button B. optional now?
delay(2000); // fastled setup.
FastLED.addLeds<SK6812, 27, GRB>(leds, 0,1); // GRB ordering is typical
FastLED.addLeds<WS2813, DATA_PIN, GRB>(leds, 1,NUM_LEDS);
FastLED.setBrightness(255);
Serial.println("setup() done. Toggle with button B."); // M5Atom specific, search https://sensorstacks.com/?s=m5atom
}
void wipeStrip(int led_val) {
// 0 == onboard led button
for (cell = 1; cell <= NUM_LEDS; cell++) {
leds[cell] = led_val;
}
FastLED.show();
return;
}
void loop() {
M5.update();
if (M5.BtnB.wasPressed()) {
enable_strip = !enable_strip;
}
if (enable_strip) {
leds[0] = CRGB::Green;
} else {
leds[0] = CRGB::Red;
wipeStrip(CRGB::Black);
delay(25);
return;
}
if (++modes >= 4) {
modes = 0; // reset
}
if (modes == 0) {
wipeStrip(CRGB::Black);
} else if (modes == 1) {
wipeStrip(CRGB::Red);
} else if (modes == 2) {
wipeStrip(CRGB::Black);
} else if (modes == 3) {
wipeStrip(CRGB::Blue);
}
FastLED.show();
delay(100);
}
@supaplextor
Copy link
Author

124959105_10224569900736742_6279732638348572089_n
125106621_10224569900456735_506373311574409897_n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment