// From Arduino Projects Book
// Project 08
// Digital Hourglass
// Modified intervals and line #30
const int switchPin = 8; //Arduino pin for switch monitoring
unsigned long previousTime = 0;
int switchState = 0;
int prevSwitchState = 0;
int led = 2;
//long interval = 600000; //equivelant to 10 minutes
//long interval = 300000; //equivelant to 5 minutes
//long interval = 120000; //equivelant to 2 minutes
//long interval = 60000; //equivelant to 1 minute
//long interval = 30000; //equivelant to 0.5 minutes (30s)
long interval = 15000; //equivelant to 0.25 minutes (15s)
void setup() {
for(int x = 2; x < 8; x++){
pinMode(x, OUTPUT);
}
pinMode(switchPin, INPUT);
}
void loop() {
unsigned long currentTime = millis(); //millis() Keeps track of the time your Arduino has been running in milliseconds.
if(currentTime - previousTime > interval){
previousTime = currentTime;
digitalWrite(led, HIGH);
digitalWrite(led-1, LOW); // Need to rethink and rewrite for better control
led++;
if(led == 7){
}
}
switchState = digitalRead(switchPin);
if(switchState != prevSwitchState){
for(int x = 2; x < 8; x++){
digitalWrite(x, LOW);
}
led = 2;
previousTime = currentTime;
}
prevSwitchState = switchState;
}