/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// defining pins to conatant variables
#define redLED 6
#define yellowLED 13
#define start 2
int pbState; //reads the state of the push button
void setup()
{
// initialize the digital pin as an output.
// Pin 6 has an LED connected on most Arduino boards:
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(start, INPUT);
}
void loop()
{
pbState = digitalRead(start); //read the state pf push button in pin 2 to pbState
if (pbState == 1) //if button is pressed, Red LED glows
{
digitalWrite(redLED, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(redLED, LOW); // set the LED off
delay(1000); // wait for a second
}
else //if button is releases, yellow LED glows
{
digitalWrite(yellowLED, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(yellowLED, LOW); // set the LED off
delay(1000); // wait for a second
}
}