/**
Blinking LED simulation
When no button is pressed, The Red LED blinks on and off during 1 second.
500ms for each state.
When button1(Flash) is pressed, led is on till button release.
When button2(Black) is pressed, led is off till released.
*/
//initialize pin variable used for LED and Buttons
const int LED = 8;
const int Flash = 2;
const int Black = 13;
//initialize the buttons states
int FlashState = 0;
int BlackState = 0;
// Attempt to solve delay problem
//unsigned long millis_now;
void setup(){
pinMode(LED, OUTPUT);
pinMode(Flash, INPUT);
pinMode(Black, INPUT);
}
void loop(){
Serial.begin(9600);
FlashState = digitalRead(Flash);
BlackState = digitalRead(Black);
if (FlashState == 1)
{
digitalWrite(LED, HIGH);
}
else if (BlackState == 1)
{
digitalWrite(LED, LOW);
}
else
{
digitalWrite(LED, HIGH);
delay(500);
//output low signal
digitalWrite(LED, LOW);
delay(500);
}
}