|
How many TV shows and movies have you seen with some mysterious electronic device counting down to zero on one of those 7 segment LED displays? If we were in that situation, we would be thinking: "Wow, where did they get that in cool blue? They are usually red." "I wonder if it has a common anode or cathode?" "That would take up a lot of IO pins on an Arduino." TOO LATE! The seven segment display is a pretty simple device. Its actually just 7 LEDs (8 really including the decimal point) arranged so different combinations can be used to make numerical digits. This tutorial will show you how to wire one up and drive it with an Arduino.
Video Demo of 7 Segment LED Hardware used in this tutorial: Arduino Duemilanove board, Solderless breadboard, jumper wires, and the blue seven segment LED, or red seven segment LED Instructions: ----- If this is your first Arduino project, first go through our “Arduino: Getting Started” and “Beginning Solderless Breadboards” tutorials. ----- Keep in mind that these LEDs have a common anode, so you switch the segments on with the digital IO pin low. Use the LED calculator to calculate the resistor value to use to get the brightness you want. Connecting these LEDs directly to the Arduino IO pins will burn them out! Use a resistor between each of the following connections on your solderless breadboard. Pins number 3 and 8 are the positive voltage in. | Arduino Pin | 7 Segment Pin Connection
| | 2 | 7 (A)
| | 3 | 6 (B)
| | 4 | 4 (C) | | 5 | 2 (D)
| | 6 | 1 (E) | | 7 | 9 (F) | | 8 | 10 (G) | | 9 | 5 (DP)
|
Software The software for this demo in the video was pretty simple. In fact you should be able to do it on your own. The flow of the program is simple. - setup IO pins 2 - 9 as output pins, and set them all to HIGH (Which turns our LEDs off!) - Start the loop and call a function for each digit. Pause for 1 second between functions. An example of one of the functions: void led4() { digitalWrite(ledPin2, HIGH); digitalWrite(ledPin3, LOW); digitalWrite(ledPin4, LOW); digitalWrite(ledPin5, HIGH); digitalWrite(ledPin6, HIGH); digitalWrite(ledPin7, LOW); digitalWrite(ledPin8, LOW); digitalWrite(ledPin9, LOW); }
I suggest at least trying write the program yourself, but if need to see the code that I used for the video, you can download it here. Just be warned its really simple code. Happy hacking. Send feedback on this tutorial here.
|