Thanks Henry_Best, is that code for a library? or some code i have to insert in to my sketch? and if so im only tinker with arduino . I do not know how to make a library or even how to edit a library! and that is why i use ready made librarys like Mr gammons <LedFlasher.h> and <LedFader.h> librarys that have been posted for all of us to use.
And thanks Delta_G , a state machine (not a state engine) Sorry! To late ive posted it now .
Charles Babbage’s state engine (mechanical) computer 1837…Analytical mechanical Engine
Alan Turing’s computer (the finite state machine) 1941…Valve electric Computer
OK! I should of said in my (first post) that i have a problem with Mr gammons <LedFader.h> library.
When i run my program on my breadboard i have a strange anomaly, Orange led fade up, but with no fade down, just OFF? is it a conflict with the red led going on?
digitalWrite (LEDredPin, HIGH); digitalWrite (LEDredPin, LOW);
But when i run a test <LedFader.h> library program to test the leds and resistors and timing on my breadboard. I works perfectly on fade up, and fade down .
Why is this so? Why does the library program work fine when i test it as a (standalone) test on my breadboard!
But when i incorporate the library into my sketch it has the strange anomaly of (Orange led fade up, but with no fade down, just OFF?) Why?
Heres my sketch, its a bit ragged around the edges. and it looks a mess . (BUT IT WORKS) and thats all i care about . so no LOL’s and WTF is that . it works for me.
All i would like is a library that can fade up–for 2 seconds–hold–then fade down for 2 seconds…
without it just going off on fade down.
// pin assignments
const byte StrobePin = 12; // PWM does what it does!!(flash)and keeps on flashing..
const byte LEDorangePin = 9; // PWM fades up (but does not fade down??? WHY???
const byte LEDredPin = 8; // Goes on for one second just before the orange goes out
const byte FloodlightPin = 7; // Goes on, and (stays) on at the very, very, start
// Fader pin min max millis on? stop?
LedFader LEDorangeFader (LEDorangePin, 0, 200, 6000, false, true); //= 6 secs
// Flasher pin off-time on-time on?
LedFlasher strobe (StrobePin, 900, 100, false); // = One second
// states for the state machine
wantFloodlight, // ALWAYS STAYS (ON) after the start up sequence.
wantStrobe, // ALWAYS STAYS (ON) after the start up sequence.
wantLEDredstartup, // Goes on for one sec when the orange led is on (at end)
wantLEDorangestartup, // Startup Orange mode
wantLEDorangeon, // Orange mode (ON)
wantLEDredon, // Red LED orange mode,Goes on when orange led is on (at end)
wantLEDorangeoff, // Orange mode (OFF)
wantLEDredoff, // Red LED orange mode,Goes (off) when orange led goes out..
// state machine variables
states state = initialState;
unsigned long lastStateChange = 0;
unsigned long timeInThisState = 1000;
void setup ()
pinMode (FloodlightPin, OUTPUT);
pinMode (StrobePin, OUTPUT);
pinMode (LEDredPin, OUTPUT);
// set up faders, flashers
} // end of setup
void doStateChange ()
lastStateChange = millis (); // when we last changed states
timeInThisState = 1000; // default one second between states
state = wantFloodlight;
digitalWrite (FloodlightPin, HIGH);
state = wantStrobe;
state = wantLEDorangestartup;
state = wantLEDredon;
timeInThisState = 6000;
digitalWrite (LEDredPin, HIGH);
state = wantLEDorangeoff;
timeInThisState = 2000;
digitalWrite (LEDredPin, LOW);
state = wantLEDorangestartup;
} // end of switch on state
} // end of doStateChange
void loop ()
if (millis () - lastStateChange >= timeInThisState)
// update fader, flasher
} // end of loop