This was written for an Adafruit Pro Trinket using the Adafruit Arduino IDE in C++, so just to be safe I can’t guarantee it will work for you.
#include <Adafruit_NeoPixel.h>
const int buttonPin = 18; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int strandPin = 6;
const int neopixelNumber = 60; //[INSERT # OF NEOPIXELS YOU HAVE HERE!]
Adafruit_NeoPixel strip = Adafruit_NeoPixel(neopixelNumber, strandPin, NEO_GRB + NEO_KHZ800);
int mode = 0;
int max_mode = 8;
int lastButton = 1;
long lastMillis = 0;
int brightness = 128;
uint32_t fire_hot = strip.Color(200, 200, 255); // light blue
uint32_t fire_cool = strip.Color(0, 0, 255); // blue
uint32_t lerp(uint32_t color0, uint32_t color1, int alpha);
int highlight = 0;
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}
void loop() {
fire();
strip.show();
}
void setPixel(int i, uint32_t color) {
int red = (color >> 16) & 0xFF;
int green = (color >> 8) & 0xFF;
int blue = color & 0xFF;
red = (red * brightness) >> 8;
green = (green * brightness) >> 8;
blue = (blue * brightness) >> 8;
strip.setPixelColor(i, strip.Color(red, green, blue));
}
void fire() {
for (int i = 0; i < neopixelNumber; ++i)
ember(i);
}
void ember(int i) {
int alpha = random(257);
uint32_t color = lerp(fire_cool, fire_hot, alpha);
setPixel(i, color);
}
#define _r(color) (((color)>>16)&0xFF)
#define _g(color) (((color)>>8)&0xFF)
#define _b(color) ((color)&0xFF)
uint32_t lerp(uint32_t color0, uint32_t color1, int alpha) {
int r = (_r(color0) * (256-alpha) + _r(color1) * alpha) >> 8;
int g = (_g(color0) * (256-alpha) + _g(color1) * alpha) >> 8;
int b = (_b(color0) * (256-alpha) + _b(color1) * alpha) >> 8;
return strip.Color(r, g, b);
}
If this code does not work for you, you can double check it against the original code posted to Valkyries Page here.