M5Stack Atom Echo LED control with M5Unified and FastLED
-
Hi everyone,
I have an M5Stack Atom Echo development kit that I’d like to program using the Arduino platform. According to the official recommendation, I’d like to use the M5Unified library.My problem is that I can’t control the LED at all with the M5Unified + FastLED combination - it just stays lit in white. The exact same example code works perfectly with FastLED + the old M5Stack library, but as soon as I switch it to M5Unified, it doesn’t work.
Does anyone have an idea how to make it work?Not working code:
#include <M5Unified.h> #include <FastLED.h> #define NUM_LEDS 1 #define DATA_PIN 27 CRGB leds[NUM_LEDS]; void setup() { auto cfg = M5.config(); M5.begin(cfg); FastLED.addLeds<SK6812, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.clear(); FastLED.show(); } ...Working code with the old, deprecated lib:
#include <M5Atom.h> #include <FastLED.h> #define NUM_LEDS 1 #define DATA_PIN 27 CRGB leds[NUM_LEDS]; void setup() { M5.begin(true, false, true); FastLED.addLeds<SK6812, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.clear(); FastLED.show(); } ... -
I like how you’re tackling LED control on the M5Stack Atom Echo using M5Unified + FastLED. The core problem of the LED staying white when switching to Unified is something others have run into too. For a similar discussion on controlling Atom Matrix LEDs using FastLED, you can check out https://community.m5stack.com/topic/visit site2230/controlling-atom-matrix-leds.
-
Using M5Stack Atom Echo with M5Unified and FastLED is a smart combo. If you're going for tight control over the LEDs, make sure your timing loop is well-optimized and that you're handling brightness safely (to avoid flicker or overheating). Also, consider breaking your effects into functions so you can easily expand or tweak them later.
-
I think this is the solution.
pinMode(DATA_PIN, OUTPUT) is the KEY which set the GPIO pin of LED mode to output.auto cfg = M5.config(); M5.begin(cfg); pinMode(DATA_PIN, OUTPUT); // <- Add this FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS); FastLED.setBrightness(50); -
The LED stays white because M5Unified controls it by default, which conflicts with FastLED. You need to turn off M5Unified’s built-in LED control first. Once that’s disabled, FastLED will work normally.
-
@sei
It really was just this one thing that was missing, and now it works.
Thank you very much. :)I have already read through several forums and tried multiple AI tools, but I could not find the solution in any of them. With this, however, it truly works. I do not understand why these things are not properly documented somewhere.
-
Thank you for the advice.
-
@AustinSmith
Unfortunately, no matter how I tried to disable it using M5Unified, I could not get it to work. In the end, adding the line suggested above finally solved the issue.pinMode(DATA_PIN, OUTPUT); // <- Add this