Yeah, they blink all three in order first once and do the fade/sweep after that. At least, the original part is still in ![]()
septillion:
Yeah, they blink all three in order first once and do the fade/sweep after that. At least, the original part is still in
https://gfycat.com/OrdinarySecondhandFairyfly
Hmm, they don't seem to fade after that?
Ahh, but they do flicker quick. Aka, what did I do wrong now ![]()
Cleaned it a bit, back to debug
#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();
}
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].getCurrent() >= 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();
}
}
}
Does this fade the first led up and down once?
#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
}
if((sines[0].getCurrent() >= 45) && sines[1].done() && (sines[1].get() == 0)){
sines[1].on();
}
}
And this?
septillion:
Ahh, but they do flicker quick. Aka, what did I do wrong nowCleaned it a bit, back to debug
#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();
}
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].getCurrent() >= 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();
}
}
}
Does this fade the first led up and down once?#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
}
if((sines[0].getCurrent() >= 45) && sines[1].done() && (sines[1].get() == 0)){
sines[1].on();
}
}
And this?
First one fades the LED up then down.
Second one however fades the first one up and down but the second one starts midway through the first one ![]()
Much better!
But what did I do wrong with that loop then...
Unlooped for the third as well:
#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
}
if((sines[0].getCurrent() >= 45) && sines[1].done() && (sines[1].get() == 0)){
sines[1].on();
}
if((sines[1].getCurrent() >= 45) && sines[2].done() && (sines[2].get() == 0)){
sines[2].on();
}
}
septillion:
But what did I do wrong with that loop then...Unlooped for the third as well:
#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
}
if((sines[0].getCurrent() >= 45) && sines[1].done() && (sines[1].get() == 0)){
sines[1].on();
}
if((sines[1].getCurrent() >= 45) && sines[2].done() && (sines[2].get() == 0)){
sines[2].on();
}
}
It works!! ![]()
Thank you!
Now ill just add and change what I need and it should be golden!
Thanks again.
What the heck did I do wrong in the looped one... Can you test:
#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
if(i > 0){
if((sines[i - 1].getCurrent() >= 45) && sines[i].done() && (sines[i].get() == 0)){
sines[i].on();
}
}
}
}
septillion:
What the heck did I do wrong in the looped one... Can you test:#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();
}
void loop(){
FadeLed::update();
for(byte i = 0; i < NrSines; i++){
//if sin is 100% (90 degree), fade back down
if(sines[i].done() && sines[i].get()){
sines[i].off();
}
if(i > 0){
if((sines[i - 1].getCurrent() >= 45) && sines[i].done() && (sines[i].get() == 0)){
sines[i].on();
}
}
}
}
Same as the last code. LED1 phases on and off, LED2 comes in at ~50% and same with LED3. Only once though (no loop).
Okay, so it does what it needs? If so, use the last (as it's dead easy to extend to 4, 5, 6 etc).
Still don't know what I did wrong earlier but I'm glad it works now. ![]()
But note again, the frequency of pin 5 and 6 differs from 9, 10, 11 and 3!
septillion:
Okay, so it does what it needs? If so, use the last (as it's dead easy to extend to 4, 5, 6 etc).Still don't know what I did wrong earlier but I'm glad it works now.
But note again, the frequency of pin 5 and 6 differs from 9, 10, 11 and 3!
Will do!
Thanks again
Small update:
I finally got around to make a new release of FadeLed! Thank god for national holiday (Kings day)!
v1.5.0 now includes gamma tables at construct ![]()