int count=0;
int newcount;
void setup()
{
Serial.begin(9600);
pinMode(2,INPUT); //push button
pinMode(13,OUTPUT); //red led
pinMode(6,OUTPUT); //blue led
pinMode(12,OUTPUT); // green led
}
void loop()
{
if(digitalRead(2)==HIGH)
{
newcount=count+1;
if(newcount!=count)
{
Serial.println(newcount);
switch (newcount)
{
case 1: digitalWrite(13,HIGH);
break;
case 2: digitalWrite(13,LOW);
break;
case 3: digitalWrite(6,HIGH);
break;
case 4: digitalWrite(6,LOW);
break;
case 5: digitalWrite(12,HIGH);
break;
case 6: digitalWrite(13, HIGH);
digitalWrite(6, HIGH);
digitalWrite(12, HIGH);
break;
default: digitalWrite(13,LOW);
digitalWrite(6,LOW);
digitalWrite(12,LOW);
newcount=0;
break;
}
count=newcount;
}
}
delay(130);
}
Comments