Push Button With 7 Segment Display
by atharvadhamorikar in Circuits > Arduino
11949 Views, 1 Favorites, 0 Comments
Push Button With 7 Segment Display
In this instructable, I made a 7 Segment pushbutton counting.Using TinkerCad
Supplies
Supply = *Only TinkerCad
Connections
Connect all the components as shown. Use a 500Ω to 1kΩ Resistor to connect the 7 segment display with a negative line. *use a Common Cathode 7 segment display also use a 1kΩResistor to connect push button.
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
Now you are done enjoy : )