// Q-8 Write a program to interface LEDs at pins 10,11,12,13 amd button at pins 7. the press of first time
// button at pin 7(increment button) is pressed first led at pin 10 is switched on, when second time button
// is pressed the next led at 11 is switched on. Similarly , when the button at pin 8 (decrement button)
// is pressed the LedS ARE switched off sequentially.
int yled=13;
int bled=12;
int gled=11;
int rled=10;
int btn1=7;
int btn2=8;
void setup() {
// put your setup code here, to run once:
pinMode(yled, OUTPUT);
pinMode(bled, OUTPUT);
pinMode(gled, OUTPUT);
pinMode(rled, OUTPUT);
pinMode(btn1, INPUT);
pinMode(btn2, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int data1=digitalRead(btn1);
int data2=digitalRead(btn2);
static int c=0;
//Serial.print(data1);
//Serial.print(c);
if(data1==HIGH)
{
digitalWrite(yled, HIGH);
if(c==1)
{
digitalWrite(bled, HIGH);
}
else
if(c==2)
{
digitalWrite(gled, HIGH);
}
else
if(c==3)
{
digitalWrite(rled, HIGH);
}
c++;
}
delay(100);
if(data2==HIGH)
{
digitalWrite(rled, LOW);
if(c==3)
{
digitalWrite(gled, LOW);
}
else
if(c==2)
{
digitalWrite(bled, LOW);
}
else
if(c==1)
{
digitalWrite(yled, LOW);
}
c--;
}
delay(100);
}