-
-
Save todbot/c22a071d6e0bc711d8746d283c1aac99 to your computer and use it in GitHub Desktop.
// modeled after https://github.com/todbot/qtpy-tricks#fire-simulation-on-external-neopixel-strip | |
// must use latest FastLED checkout from https://github.com/FastLED/FastLED | |
// as FastLED 3.3.3 doesn't have QT Py support | |
#include "FastLED.h" | |
#define LED_PIN 0 | |
#define NUM_LEDS 8 | |
CRGB leds[NUM_LEDS]; | |
void setup() { | |
FastLED.addLeds<WS2812, LED_PIN,GRB>(leds, NUM_LEDS); | |
FastLED.setBrightness( 50 ); // out of 255 | |
} | |
void loop() { | |
// dim all LEDs by (30,30,30) | |
for(int i=0; i<NUM_LEDS; i++) { | |
leds[i] -= CRGB(30,30,30); | |
} | |
// shift LEDs down by one | |
for(int i=NUM_LEDS-1; i>0; i--) { | |
leds[i] = leds[i-1]; | |
} | |
// set first LED to random fire color | |
leds[0] = CRGB( random(150,255), random(50,100), 0); | |
FastLED.show(); | |
delay(100); | |
} |
Apologies, I was using the latest FastLED checkout from github, not the one in the Library Manager (the github checkout version is still 3.3.3, confusingly) And there hasn't been a FastLED full release yet with QT Py support.
If you are familiar with git
you can use it to replace the FastLED library in your Arduino "libraries" directory. On a Mac in terminal this would look like:
cd $HOME/Documents/Arduino/libraries
rm -rf FastLED
git clone https://github.com/FastLED/FastLED
and then recompiling in the Arduino IDE.
In Windows and without git
you can download a zipfile of the repository by clicking on the "Code" button and clicking "Download ZIP" (see screenshot below). Then place that zip file in your "Documents/Arduino/libraries" folder, right-click on it to Extract All, and then rename the resulting folder of "FastLED-master" to just "FastLED"
Thank you for the code.
I tried increasing the number of LEDs to 30, but it seems only 9 work.
Hi @Yousefff1,
You will need to decrease the amount of fading from CRGB(30,30,30)
to something like CRGB(10,10,10)
Thank you! I'll test it out.
I appreciate it!
Hi,
I get this FastLED "No pin/port mappings found" error. I posted the whole error message below. Can you help me with fix this error?
Thanks,
Lou