septillion:
Can you run one with a bit of debug Serial?#include <FadeLed.h>
//91 step sine table 0 = 0 degree, 90 = 90 degree
const flvar_t SineTable[91] PROGMEM = {
0, 4, 9, 13, 18, 22, 27, 31, 35, 40,
44, 49, 53, 57, 62, 66, 70, 75, 79, 83,
87, 91, 96, 100, 104, 108, 112, 116, 120, 124,
127, 131, 135, 139, 143, 146, 150, 153, 157, 160,
164, 167, 171, 174, 177, 180, 183, 186, 190, 192,
195, 198, 201, 204, 206, 209, 211, 214, 216, 219,
221, 223, 225, 227, 229, 231, 233, 235, 236, 238,
240, 241, 243, 244, 245, 246, 247, 248, 249, 250,
251, 252, 253, 253, 254, 254, 254, 255, 255, 255,
255};
//Make FadeLed object with a sine lookup table of 91 (0 to 90 including)
FadeLed sines[3] = {{3, SineTable, 90}, {5, SineTable, 90}, {9, SineTable, 90}};
const byte NrSines = sizeof(sines)/sizeof(sines[0]);
void setup(){
Serial.begin(115200);
for(byte i = 0; i < NrSines; i++){
sines[i].setTime(1000); //halve period, 0% to 90% or 90% to 0%
}
//start the first
sines[0].on();
Serial.println(NrSines);
Serial.println();
for(byte i =0; i < NrSines; i++){
Serial.println(sines[i].get())
Serial.println(sines[i].getCurrent());
Serial.println(sines[i].done());
Serial.println();
}
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//for all but last (who has no next)
if(i < (NrSines - 1)){
//if >50% (45 degree) and next is not fading and is off
if((sines[i].get() >= 45) && !sines[i + 1].done() && (sines[i + 1].get() == 0)){
sines[i + 1].on();
}
}
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
}
}
And post the serial output (in text please) here.
3
90
0
0
0
0
1
0
0
1