Hello Everyone! I am new to Arduino and I have a question. Why is 0001 is not displaying correctly? It does not follow the 1-second delay I coded. Thank you for the help!
This will light up 4 LEDs depending on the value.
SOURCE CODE:
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop()
{
digitalWrite(2,0);//0000
digitalWrite(3,0);
digitalWrite(4,0);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,1);//0001
digitalWrite(3,0);
digitalWrite(4,0);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,0);//0010
digitalWrite(3,1);
digitalWrite(4,0);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,1);//0011
digitalWrite(3,1);
digitalWrite(4,0);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,0);//0100
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,1);//0101
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,0);//0110
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,1);//0111
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,0);
delay(1000);
digitalWrite(2,0);//1000
digitalWrite(3,0);
digitalWrite(4,0);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,1);//1001
digitalWrite(3,0);
digitalWrite(4,0);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,0);//1010
digitalWrite(3,1);
digitalWrite(4,0);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,1);//1011
digitalWrite(3,1);
digitalWrite(4,0);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,0);//1100
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,1);//1101
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,0);//1110
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,1);
delay(1000);
digitalWrite(2,1);//1111
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,1);
delay(1000);
}``'