int ledy = 5 ;
int leds = 4 ;
int ledk = 3;
int button = 2 ;
int count = 0 ;
void setup()
{
pinMode(ledy, OUTPUT);
pinMode(leds, OUTPUT);
pinMode(ledk, OUTPUT);
pinMode(button,INPUT);
randomSeed(analogRead(A0));
}
void loop()
{
if(digitalRead(button)== HIGH)
{
count = count++ ;
}
if (count==1)
{
digitalWrite(ledk, HIGH);
digitalWrite(leds, LOW);
digitalWrite(ledy, LOW);
}
else if (count==2)
{
digitalWrite(ledk, LOW);
digitalWrite(leds, HIGH);
digitalWrite(ledy, LOW);
}
else if (count==3)
{
digitalWrite(ledk, LOW);
digitalWrite(leds, LOW);
digitalWrite(ledy, HIGH);
}
delay(1000);
}
I don't undertstand why it isn't working. I want it three leds to light up one by one as loop. But none of them lights up.
count = count++which (I guess) does not do what you think it does. Replace it with eithercount++orcount = count + 1. It might also be a good idea to reset the counter after it reaches 3.