loading

Check out how to make your own 7 segment click counter!!

Step 1: Materials You Will Need:

1x Arduino Board(does not matter which version).

1x BreadBoard.

1x 1 Digit 7 Segment display.

2x Push Buttons.

4x 220 ohm resistors(Will work up to 1K).

16x Male to male jumper wires.

Step 2: Connect the Arduino to the BreadBoard:

Connect as shown in the image above:

Arduino 5V pin to the PLUS of the breadboard.

Arduino GND to the MINUS of the breadboard.

7-Segment pin 8 & 3 to the PLUS of the breadboard through your resistors.

NOTE: if your 7 segment display is a common cathode display, connect pins 8 & 3 of the display to the GND!!

7-Segment pin 1 to Arduino pin 6.

7-Segment pin 2 to Arduino pin 5.

7-Segment pin 4 to Arduino pin 4.

7-Segment pin 5 to Arduino pin 7.

7-Segment pin 6 to Arduino pin 2.

7-Segment pin 7 to Arduino pin 3.

7-Segment pin 9 to Arduino pin 8.

7-Segment pin 10 to Arduino pin 9.

Connecting the buttons:

connect one side of the button to the PLUS of the breadboard;

connect the other side through a resistor to the GND of the breadboard, and to Arduino pin 12.

Do that for the second button and connect it to Arduino pin 13.

Step 3: The Code:

Download the code and insert it to arduino IDE, and have fun!!

Write your comments down bellow!!

<p>how can i add 2 more digits</p>
<p>Can you sent it to me?</p>
<p>I sent you a private message, check it.</p>
<p>Can you help with it too please</p>
Please send me how to add another 1 digit and how the would be look like many thanks
How the code would be look like when added another 1 digit
<p>can you give it to me too? pleaseeee</p>
<p>can u give me also a two digit? please. thanks</p>
<p>please give me too, i need to add 1 more digit</p>
<p>A very helpful and educational instructable. I specially appreciated the comment from KoKoY2 to convert the code to common cathode.</p>
<p>Thank you.... it helped me.I used seven segment common cathode and i edited HIGH and LOW states.Here for common cathode...</p><p>//Initialize the 7 segment pins<br>int A = 3;<br>int B = 2;<br>int C = 4;<br>int D = 5;<br>int E = 6;<br>int F = 8;<br>int G = 9;<br><br>//Initialize the push buttons pins, push buttons states, and the counter<br>int switchUpPin = 12;<br>int switchDownPin = 13;<br>int counter = 0;<br>int buttonUpState = 0;<br>int lastButtonUpState = 0;<br>int buttonDownState = 0;<br>int lastButtonDownState = 0;<br><br>void setup() <br>{<br> Serial.begin(9600);<br> <br> pinMode(A, OUTPUT);<br> pinMode(B, OUTPUT);<br> pinMode(C, OUTPUT);<br> pinMode(D, OUTPUT);<br> pinMode(E, OUTPUT);<br> pinMode(F, OUTPUT);<br> pinMode(G, OUTPUT);<br> <br>}<br><br>void loop() <br>{<br> //Getting the reads from the buttons<br> buttonUpState = digitalRead(switchUpPin);<br> buttonDownState = digitalRead(switchDownPin);<br><br> //Detecting button press and getting the button status<br> //Do this for the button up<br> if (buttonUpState != lastButtonUpState) <br> {<br> if (buttonUpState == HIGH) <br> {<br> //Reset the counter to -1<br> if(counter == 9)<br> {<br> counter = -1;<br> }<br> //Increase the counter by 1<br> counter++;<br> //Print the counter to the console and calling the function<br> Serial.println(counter);<br> changeNumber(counter);<br> //Delaying by 250 ms<br> delay(250);<br> }<br> else<br> {<br> Serial.println(&quot;OFF&quot;);<br> }<br> //Delay to avoid button bouncing<br> delay(50);<br> }<br><br> //Do this for the button down<br> if (buttonDownState != lastButtonDownState) <br> {<br> if (buttonDownState == HIGH) <br> {<br> //Set the counter to 10<br> if(counter == 0)<br> {<br> counter = 10;<br> }<br> //Decreases the counter by 1<br> counter--;<br> ////Print the counter to the console and calling the function<br> Serial.println(counter);<br> changeNumber(counter);<br> //Delaying by 250 ms<br> delay(250);<br> }<br> else<br> {<br> Serial.println(&quot;OFF&quot;);<br> }<br> //Delay to avoid button bouncing<br> delay(50);<br> }<br> //Calling the function changeNumber with the arg counter<br> changeNumber(counter);<br>}<br><br>//The function to display the numbers<br>void changeNumber(int buttonPress)<br>{<br> switch (buttonPress)<br> {<br> //number 0<br> case 0:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, HIGH);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, LOW);<br> break;<br> //number 1<br> case 1:<br> digitalWrite(A, LOW);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, LOW);<br> digitalWrite(E, LOW);<br> digitalWrite(F, LOW);<br> digitalWrite(G, LOW);<br> break;<br> //number 2<br> case 2:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, LOW);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, HIGH);<br> digitalWrite(F, LOW);<br> digitalWrite(G, HIGH);<br> break;<br> //number 3<br> case 3:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, LOW);<br> digitalWrite(F, LOW);<br> digitalWrite(G, HIGH);<br> break;<br> //number 4<br> case 4:<br> digitalWrite(A, LOW);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, LOW);<br> digitalWrite(E, LOW);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, HIGH);<br> break;<br> //number 5<br> case 5:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, LOW);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, LOW);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, HIGH);<br> break;<br> //number 6<br> case 6:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, LOW);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, HIGH);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, HIGH);<br> break;<br> //number 7<br> case 7:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, LOW);<br> digitalWrite(E, LOW);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, LOW);<br> break;<br> //number 8<br> case 8:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, HIGH);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, HIGH);<br> break;<br> //number 9<br> case 9:<br> digitalWrite(A, HIGH);<br> digitalWrite(B, HIGH);<br> digitalWrite(C, HIGH);<br> digitalWrite(D, HIGH);<br> digitalWrite(E, LOW);<br> digitalWrite(F, HIGH);<br> digitalWrite(G, HIGH);<br> break;<br> }<br>}</p>
<p>GOOD IT HELPED ME A LOT</p>
<p>i have a problem in my seven segment, if use the common anode, the seven segment isn't displaying anything, if use the the common cathode, some of the segments are not working. help pls</p>
<p>after fooling around i found a solution. flip around the code for the leds in the segment display i.e. if it says digitalWrite (A,HIGH); switch it to digitalWrite(A,LOW);</p>
<p>how to make two digit one pls :) text me. Thanks a lot </p>
Great instructions. Thank you for sharing how you made this little counter! :)
<p>Thanks, appreciate that :)</p>

About This Instructable

7,371views

8favorites

More by YahavHadad:Arduino 7-Segment Click Counter 
Add instructable to: