# include "jbutton.h"
int red = 9;
int amber = 8;
int green = 7;
jButton pushbutton; // not... // pin 12, 20 ms debounce time
int counter = 1;
int countTo = 1;
void setup(){
pinMode(red, OUTPUT);
pinMode(amber, OUTPUT);
pinMode(green, OUTPUT);
pinMode(12, INPUT_PULLUP);
pushbutton.begin(12);
Serial.begin(9600);
randomSeed(analogRead(0)); // Initialize random seed
}
void loop(){
Serial.println("Red Only...");
digitalWrite(red, HIGH);
delay(3000);
// Red & Amber
Serial.println("Red & Amber...");
digitalWrite(amber, HIGH);
delay(3000);
digitalWrite(red, LOW);
digitalWrite(amber, LOW);
//green only)
Serial.println("Green Only...");
digitalWrite(green, HIGH);
counter = 1;
countTo = 77; //random(1000, 30000); // end plan is to generate random number of cycles between 1000 and 10000
// This will stay on green for a random time (approx 30 seconds to 15 minutes) unless button pushed
while (counter < countTo) {
// madleech has no service call pushbutton.loop ();
pushbutton.update();
Serial.print(" Counter:");
Serial.print(counter);
Serial.print (" Random Cycles:");
Serial.println (countTo);
counter = counter + 1;
if (pushbutton.uolPress()) { //when button pushed, set counter to countTo which exits while loop to continue to Amber
counter = countTo;
}
}
//Amber only
Serial.println("Amber Only...");
digitalWrite(green, LOW);
digitalWrite(amber, HIGH);
delay(4000);
digitalWrite(amber, LOW);
}