7 Segment Display Counter With Pushbutton
by atharvadhamorikar in Circuits > Arduino
482 Views, 1 Favorites, 0 Comments
7 Segment Display Counter With Pushbutton
Hi, I made a 7 segment display counter with tinkercad.
Supplies
*only TINKERCAD.
Connections
CONNECT AS FOLLOWS.
Code
Code :-
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9,INPUT);
Serial.begin(9600);
}
void loop()
{
int x=digitalRead(9);
Serial.println(x);
delay(500);
if(x==1)
{
digitalWrite(2,0);//1
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,0);
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(8,0);
delay(1000);
digitalWrite(2,1);//2
digitalWrite(3,1);
digitalWrite(4,0);
digitalWrite(5,1);
digitalWrite(6,1);
digitalWrite(7,0);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,1);//3
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,0);//4
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,0);
digitalWrite(6,0);
digitalWrite(7,1);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,1);//5
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(6,0);
digitalWrite(7,1);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,1);//6
digitalWrite(3,0);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(6,1);
digitalWrite(7,1);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,1);//7
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,0);
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(8,0);
delay(1000);
digitalWrite(2,1);//8
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(6,1);
digitalWrite(7,1);
digitalWrite(8,1);
delay(1000);
digitalWrite(2,1);//9
digitalWrite(3,1);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(6,0);
digitalWrite(7,1);
digitalWrite(8,1);
delay(1000);
}
else(x==0);
{
digitalWrite(2,0);
digitalWrite(3,0);
digitalWrite(4,0);
digitalWrite(5,0);
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(8,0);
delay(1000);
}
}
Testing
DONE Do like my video and subscribe to my channel : )