const int REDpin = 3;
const int GREENpin = 4;
const unsigned long REDonDuration = 1000; // OFF time for RED led
const unsigned long REDoffDuration = 250; // ON time for RED led
bool REDState =HIGH; // initial state of RED led
const unsigned long GREENonDuration = 325; // OFF time for RED led
const unsigned long GREENoffDuration = 950; // ON time for RED led
bool GREENState =HIGH; // initial state of RED led
unsigned long REDpm=0; // RED led previous millis
void setup() {
pinMode(REDpin,OUTPUT); // define REDpin as output
digitalWrite(REDpin,REDState); // set initial RED state
pinMode(GREENpin,OUTPUT); // define REDpin as output
digitalWrite(GREENpin,GREENState); // set initial RED state
}
void loop() {
if( REDState == HIGH)
{
if( (millis()- REDpm) >= REDonDuration)
{
REDState = LOW; // change the state of RED led
REDpm=millis(); // remember current RED millis() time
}
}
else
{
if( (millis()- REDpm) >= REDoffDuration){
REDState =HIGH; // change the state of RED led
REDpm=millis(); // remember current RED millis() time
}
}
digitalWrite(REDpin,REDState); // command RED led
digitalWrite(GREENpin,GREENState); // command RED led
}