7 Segment Display Example

7 Segment Display Example

The 7 Segment Display is an electronic device used mainly to view the numeric digits through switch on of leds. There are two possible configuration: common anode and common cathode. The display is formed by ten pins, in the common anode seven are the cathodes of leds, two are the common anodes and one is for decimal point, instead in the common cathode seven pins are the anodes of leds, two the common cathodes and one is for decimal point. Every pin of display is called with an alphabet letter as shown in the figure. In this example is used a Display common anode to count from 0 to 9 and from 9 to 0.

Hardware Required

Arduino Board

7 Segment Display with common anode

Wires

Breadboard

7 resistors of 220 Ω

Circuit

Connect the cathodes of leds in series to a resistor of 220 Ω and after connect them to the digital pins of board. Finally connect the common anodes (pin 3 and 8 of display) to Pin 5V of board.

Schematic

Code

The sketch defines the variables used to switch on the corresponding segment display, the alphabet letters represent the segments of display, instead the numbers are the digital Pins used to connect the display to the board. The function Led_on defines how to realize the numbers on display. In the setup the Pins of Display are defined as OUTPUT. In the loop it is called the function Led_on to count from 0 to 9 and from 9 to 0. Note: When you use a display at common anode if you write LOW you switch on a segment else if you write HIGH you switch off it, instead when you use a display at common cathode you must write in opposite mode.