int pin2 = 2; // Setting the value of variable pin2 as 2
int pin3 = 3; // Setting the value of variable pin3 as 3
int pin4 = 4; // Setting the value of variable pin4 as 4
int pin5 = 5; // Setting the value of variable pin5 as 5
void setup() {
// put your setup code here, to run once:
pinMode (pin2,OUTPUT); //Defining pin2 as OUTPUT
pinMode (pin3,OUTPUT); //Defining pin3 as OUTPUT
pinMode (pin4,OUTPUT); //Defining pin4 as OUTPUT
pinMode (pin5,OUTPUT); //Defining pin5 as OUTPUT
}
void loop() {
// put your main code here, to run repeatedly:
// 0000 = 0
// 0001 (1)
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,HIGH);
delay (1000); // giving a gap of 1000 miilliseconds, 1 second = 1000 milliseconds
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0010 (2)
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0011 (3)
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0100 (4)
digitalWrite (pin2,LOW);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0101 (5)
digitalWrite (pin2,LOW);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,LOW);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0110 (6)
digitalWrite (pin2,LOW);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 0111 (7)
digitalWrite (pin2,LOW);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1000 (8)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1001 (9)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1010 (10)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,LOW);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1011 (11)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,LOW);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1100 (12)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1101 (13)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,LOW);
digitalWrite (pin5,HIGH);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1110 (14)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,LOW);
delay (1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (1000);
// 1111 (15)
digitalWrite (pin2,HIGH);
digitalWrite (pin3,HIGH);
digitalWrite (pin4,HIGH);
digitalWrite (pin5,HIGH);
delay(1000);
digitalWrite (pin2,LOW);
digitalWrite (pin3,LOW);
digitalWrite (pin4,LOW);
digitalWrite (pin5,LOW);
delay (2000);
}
Comments