Hi Hans,
After sorting out the fire routine, I was wondering if you could look at this...
Its something I've been playing with this week, I got it working (sort of) but for some reason It just wont work anymore when I upload the sketch. I added the serial prints to see where it gets up to but it actually locks up regulary reporting "Startup r" and not "Startup running..."
My idea was to make the leds look like dumb leds for a few seconds, fizzle out, then have your Meteor rain sequence to look like a fuse before igniting the Fire sequence (not added yet)
I managed to get it to work about 3 times then it locks up... I can run any other code over the leds (DemoReel) but mine just locks up. Last night the leds just went nuts and very random even though I changed nothing major.
Its not tidy so if you can look at it and suggest whats going on it would be great.
I added the serial.println routines just so I could see where it was locking up.
#include "FastLED.h"
#include "SoftwareSerial.h"
#define NUM_LEDS 75
CRGB leds[NUM_LEDS];
#define PIN 3
#define Brightness 40
// strip lengths
#define S1 10 //66
#define S2 15 //142
#define S3 15 //71
#define S4 5 //91
#define S5 25 //128
int RunOnce = true ;
void setup()
{
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(Brightness);
int S2a = S1+S2 ;
int S3a = S2a+S3 ;
int S4a = S3a+S4 ;
// mySoftwareSerial.begin(9600);
Serial.begin(115200);
Serial.println("Startup running...");
//randomSeed(analogRead(0));
}
// REPLACE FROM HERE
void loop() {
Serial.println(("Main code running"));
if (RunOnce == true ){
RunOnce = false ;
// rgb(1st colour), delay, rgb (2nd Colour), how many times (3000x3)
SolidFill( 255 , 0, 0, 3000, 0, 255, 0 , 3 );
Serial.println(F("SolidFill Complete..."));
// Fizzle (red, green, blue), count, speed delay, only one twinkle (true/false)
Fizzle(0xff, 0xff, 0xff, 300, 1, true);
Serial.println(("Fizzle Complete..."));
// Fuse(); //fade in Fuse
// FastLED.setBrightness(Brightness);
}
// Move MeteorRain to below fuse in real life
// meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay
MeteorRain(0xff,0xff,0xff,2, 200, true, 50);
Serial.println(("MeteorRain Complete..."));
}
void SolidFill (int r, int g, int b, int Wait, int r1, int g1, int b1, int Times){
Serial.println(("Start SolidFill..."));
for (int x = 0 ; x <= 10 ; x++){
if (Wait >=2)
for ( int i = 0 ; i <= Times; i++){
fill_solid (leds, S1, CRGB( r, g, b));
fill_solid (leds+S1, S2, CRGB( r1, g1, b1));
fill_solid (leds+(S1+S2), S3, CRGB( r, g,b));
fill_solid (leds+(S1+S2+S3), S4, CRGB( r1, g1, b1));
fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r, g, b));
showStrip();
delay (Wait);
fill_solid (leds, S1, CRGB( r1, g1, b1));
fill_solid (leds+S1, S2, CRGB( r, g, b));
fill_solid (leds+(S1+S2), S3, CRGB( r1, g1, b1));
fill_solid (leds+(S1+S2+S3), S4, CRGB( r, g, b));
fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r1, g1, b1));
showStrip();
delay (Wait);
}
if (Wait <=1000)
// Wait1 = Wait/2;
Wait = Wait/2;
else
Wait = Wait - 1000;
}
}
void MeteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
// setAll(0,0,0);
Serial.println(("MeteorRain Started..."));
for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
fadeToBlack(j, meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
setPixel(i-j, red, green, blue);
}
}
showStrip();
delay(SpeedDelay);
}
}
// used by meteorrain
void fadeToBlack(int ledNo, byte fadeValue) {
leds[ledNo].fadeToBlackBy( fadeValue );
}
void Fizzle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
/* setAll (0,0,0);
delay (1000);
setAll(255,255,255);
delay (1000);
setAll(0,0,0);
*/
for (int i=0; i<Count; i++) {
setPixel(random(NUM_LEDS),red,green,blue);
showStrip();
delay(SpeedDelay);
if(OnlyOne) {
setAll(0,0,0);
}
}
}
void Fuse() {
for ( int r = 0 ; r <= 10 ; r++){
FastLED.setBrightness(r);
fill_solid (leds, NUM_LEDS, CRGB( 155 , 57, 15));
showStrip();
delay (200);
}
delay (3000);
}
// FastLED main sequences
// REPLACE TO HERE
void showStrip() {
FastLED.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
Many thanks
Phil