Skip to content

Instantly share code, notes, and snippets.

@todbot
Last active April 13, 2021 18:16
Show Gist options
  • Save todbot/c22a071d6e0bc711d8746d283c1aac99 to your computer and use it in GitHub Desktop.
Save todbot/c22a071d6e0bc711d8746d283c1aac99 to your computer and use it in GitHub Desktop.
Tiny fire simulation for QT Py or any FastLED-supporting board
// 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);
}
@LEDLIT1
Copy link

LEDLIT1 commented Dec 13, 2020

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

Arduino: 1.8.13 (Windows 10), TD: 1.53, Board: "Adafruit QT PY (SAMD21), Small (-Os) (standard), Arduino, Off"

In file included from C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_755081\sketch_dec13a.ino:2:

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:585:2: warning: #warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info." [-Wcpp]

  585 | #warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."

      |  ^~~~~~~

In file included from C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_755081\sketch_dec13a.ino:2:

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

   14 | #    pragma message "FastLED version 3.003.003"

      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:65,

                 from C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_755081\sketch_dec13a.ino:2:

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/fastspi.h:130:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

  130 | #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:48,

                 from C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_755081\sketch_dec13a.ino:2:

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/fastpin.h: In instantiation of 'class FastPin<0>':

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/fastpin.h:239:29:   required from 'class FastPinBB<0>'

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/platforms/arm/d21/clockless_arm_d21.h:10:52:   required from 'class ClocklessController<0, 12, 30, 18, GRB, 0, false, 50>'

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/chipsets.h:582:7:   required from 'class WS2812Controller800Khz<0, GRB>'

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:103:52:   required from 'class WS2812<0, GRB>'

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/FastLED.h:302:39:   required from 'static CLEDController& CFastLED::addLeds(CRGB*, int, int) [with CHIPSET = WS2812; unsigned char DATA_PIN = 0; EOrder RGB_ORDER = GRB]'

C:\Users\jlcel\AppData\Local\Temp\arduino_modified_sketch_755081\sketch_dec13a.ino:9:55:   required from here

C:\Users\jlcel\Documents\Arduino\libraries\FastLED/fastpin.h:207:24: error: static assertion failed: Invalid pin specified

  207 |  static_assert(validpin(), "Invalid pin specified");

      |                ~~~~~~~~^~

exit status 1

Error compiling for board Adafruit QT PY (SAMD21).



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@todbot
Copy link
Author

todbot commented Dec 13, 2020

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.

@todbot
Copy link
Author

todbot commented Dec 13, 2020

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"

Screen Shot 2020-12-13 at 12 23 06p

@Yousefff1
Copy link

Thank you for the code.

I tried increasing the number of LEDs to 30, but it seems only 9 work.

@todbot
Copy link
Author

todbot commented Apr 12, 2021

Hi @Yousefff1,
You will need to decrease the amount of fading from CRGB(30,30,30) to something like CRGB(10,10,10)

@Yousefff1
Copy link

Thank you! I'll test it out.

I appreciate it!

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