4-Digit 7-Segment LED Display + Arduino by Jimmacle
I recently got a 4-Digit 7-Segment LED Display from Sparkfun, and couldn't wait to use it. Here, I will show you how to wire it, and some sample programs to use with it!
 
Remove these adsRemove these ads by Signing Up

Step 1: Display info

This is the way the display works. It's multiplexed, so you select the digit by setting its pin (we'll get into pins later) HIGH, and you select the segment by setting its pin LOW. You display multiple digits at once by rapidly cycling through them.
The Pins (digits are numbered from the left):
Digit 1: 1
Digit 2: 2
Digit 3: 6
Digit 4: 8
 
Segment A: 14
Segment B: 16
Segment C: 13
Segment D: 3
Segment E: 5
Segment F: 11
Segment G: 15
 
Decimal Point: 7
 

SuperTech-IT says: Apr 22, 2013. 11:59 AM
I suggest about 220 ohm.
SuperTech-IT says: Apr 20, 2013. 7:17 AM
The resistors should be on the SEGMENTS, not the DIGITS (IE: pins 3,5,7,11,13,14,15,16). The way this is wired, there would be 3.5 X the current through a resistor when displaying an 8 as when displaying a 1, and this will result in brightness fluctuations. Thanks for the rest of the information though.
Jimmacle (author) says: Apr 22, 2013. 7:30 AM
Oh, I noticed the brightness changing. Thanks for the tip; I'll make a second version of this including this modification.
Thekiller578 says: Dec 24, 2012. 8:55 PM
now how to make a simple countdown timer from 30 sec and after it hits zero a buzzer goes off... any ideas?
Jimmacle (author) says: Dec 29, 2012. 8:13 AM
You could probably write a program where you set a variable and it subtracts 1 every second, then *if* it equals zero, *then* sound a buzzer. You would need to call a separate function that deals with displaying the variable's value on the display.
jacobbrunberg says: Dec 29, 2012. 7:08 AM
you could make a timer count down and then you can have a piezo buzzer go off
jacobbrunberg says: Dec 29, 2012. 7:09 AM
where dous ground cume from?
Jimmacle (author) says: Dec 29, 2012. 8:11 AM
On the display? Power comes in through the digit pins, and goes out through the segment pins.
ruthRon says: Dec 4, 2012. 7:16 AM
thank you- i got it working for the blue color with 110 ohm resistors.
for the counter code, to get the right side digit to display the second i flipped the DIGITs order from your code:
//int d4 = 9; int d3 = 10; int d2 = 11; int d1 = 12;
to:
int d4 = 12; int d3 = 11; int d2 = 10; int d1 = 9;
now it displays correctly with the fast counting digit to the right side, decimal second to the left etc.
ruthRon says: Dec 4, 2012. 12:38 AM
thanks for the tutorial! I see resistors in the pictures but not on your pin connection list. where should i put resistors and what value? thanks a lot
Jimmacle (author) says: Dec 4, 2012. 6:21 AM
Sorry, use the resistors instead of jumpers on pins 1, 2, 7, and 8 (the display selection pins). I used 1K resistors, but you could get away with something less.
salmansheikh says: May 16, 2012. 6:52 AM
How do I use the pushbutton to pause the counter rather than reset it?
Jimmacle (author) says: May 16, 2012. 4:53 PM
That is not currently in the program. You could have it set up where it only counts if the button is not pressed, for example:

void loop() {
buttonState = digitalRead(13)
if (buttonState == LOW) {
[insert counting program here]
}
salmansheikh says: May 16, 2012. 5:24 PM
Thanks. I was thinking of making a basketball game timer and also need to use the ":" that could count to 30:00 minutes or down from 30:00 to zero and pause for fouls with a push of the button. I have another display for the score but not sure one Arduino could program both displays...
Jimmacle (author) says: May 16, 2012. 11:13 PM
So you'd definitely want to replace the button with a switch, so you don't have to hold the button down. If both displays show the same thing and have the same pin configuration, it shouldn't be a problem as long as they don't draw too much current (probably not, since they're cycling through and not constantly on). Would you like me to make a program that counts down from a settable time?
salmansheikh says: May 17, 2012. 4:00 AM
No, I want do different things..one will be an game elapsed timer, the other display, two scores, one teams on left of : and one on the right. Games only go to double digits. That may require 2 more buttons and another Arduino unless I can multiplex the control signals somehow, perhaps with a 4th button.
OCPik4chu says: Oct 3, 2012. 3:40 PM
I'm by all means not an expert on the Arduino at all but do have some working programming knowledge. I would think if you instead used the button state to set a variable to 1 or 0 rather than pole the button directly you can put that in the clock loop to freeze the time if its been set. Id recommend just to Google 'Arduino stopwatch' as it should be right in line with what you want, IMO. Additionally, using shift registers would allow you to control several displays with just one Arduino. It will get more complicated if you nest registers but you can still do quite a bit. You should be able to, without it being too complicated get at least 2 7-segment digits per 1 shift register as long as you use the right one. And it would only require 2-3 pins on the Arduino for each one.
Jimmacle (author) says: Oct 3, 2012. 10:58 PM
That would probably be a better way to program the button. I would have used shift registers, but I didn't have any on hand and it would require wiring them to transistors (pins used to select segment are negative). Maybe I'll buy the parts and make another version.
KGuy says: Aug 18, 2012. 11:06 AM
I found this display in a Knex kit, as well as multiple other parts. The kit is pretty cheap, and I reccomend getting it..........http://www.ebay.com/itm/KNEX-Electronic-Arcade-Pinball-Speedball-USED-Knex-Building-Set-/350585893648?pt=LH_DefaultDomain_0&hash=item51a08c3310
Jimmacle (author) says: Aug 18, 2012. 5:33 PM
The only "problem" with that would be finding the datasheet for it, unless it's printed somewhere on the display. Other than that, it seems like a nice buy.
yonch says: Jul 31, 2012. 5:33 AM
Why not use a decoder?
Jimmacle (author) says: Jul 31, 2012. 8:41 AM
I never thought of that. I'll start designing a 2nd version. My decoder might be broken though, I don't remember and I only have one.
Jimmacle (author) says: Jul 31, 2012. 9:15 AM
After some testing, I realized that it's impossible because the digit pin needs to be HIGH and the segment pin needs to be LOW for the correct segment to turn on. The decoder outputs HIGH. I guess if I wire up an inverter for each segment it could work.
yonch says: Jul 31, 2012. 10:13 AM
So you can connect the segments to the decoder and the digit to the arduino.
Jimmacle (author) says: Jul 31, 2012. 11:23 AM
Okay, this is my setup: Arduino pins 1-4 connected to digits; pins 5-8 connected to BCD to 7-segment decoder. What you said is what I tried. Basically, you set the pins of the digits you want HIGH, and you set the pins of the segments you want LOW. Since the decoder outputs HIGH, I can't connect it to the segments, and that's the problem. I'm currently trying to find the best way to invert the signals from the BCD to 7-segment decoder.
yonch says: Jul 31, 2012. 11:45 AM
You can use transistors.
Jimmacle (author) says: Jul 31, 2012. 5:52 PM
Yeah, that's what I was thinking. I don't have enough on hand though, so I'll need to order some.
Jimmacle (author) says: Jul 31, 2012. 9:20 AM
Forgive my brainstorming on the comments, but since I don't have any NOT gates lying around, I'm going to try making them out of NOR gates.
rbarot says: Sep 26, 2011. 8:14 PM
so
Jimmacle (author) says: Sep 27, 2011. 9:05 PM
So... what?
bulb66 says: Jun 2, 2011. 9:23 AM
Nice, i can see a 7-Segment display in my future, lol

and good luck to you too for the contest
vishalapr says: Jun 1, 2011. 6:46 AM
Rated it 4*
vishalapr says: Jun 1, 2011. 6:45 AM
Cool ible roboGeekDude!!!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!