Interfacing 7 Segment Display
Many times we may need to show numbers/alphabets as outputs, 7 Segment Display is a handy device for this purpose. They usually have 8 display elements, 7 for numerics and 1 for dot. 7 Seg Disp are available in Common Anode and Common Cathode Configuration.
This is exactly equivalent to 7/8 LEDs tied together either at anode or cathode. So logic used to interface LED can be applied here. Connect the common anode to the power supply (Vcc), Connect current limiting resistor to each segment, other end of the resistor to the I/O port of microcontroller. When 0 is written to the port, corresponding segment glows. In this way by changing the word written to the port different patterns can be produced in the 7 Segment display.
Multiplexing 7 Segment display
Often we may required more than one 7 Seg Disp to show time or digits of a number. If we connected them independently to I/O ports, max only 4 digits can be connected.
This prevents the connection of other devices required by our application. Persistence of vision
can be used to display multiple digits by switching them on/off at high frequency. The idea is
1. Write the required word ot the port
2. Switch on the display
3. Short delay
4. Switch off the display
5. Move to the next display and repeat step 1
Parallel the cathodes of each segment, that is connect A of all display together, then to microcontroller port through a current limiting resistor. In the same way connect B, C, etc. Individually connect the anode to Vcc through transistor. Base of the transistor is connected to the microcontroller. When port connect to transistor Q1 is logic 1, it starts conducting, Disp 1 will show patterns based on the word written on its cathode pins. During this period everyother display need to be turned off by setting logic zero to Q2, Q3 & Q4. After a short delay turn off Disp 1 by setting zero on Q1. Write desired word on the cathode pins, enable Disp2 by setting logic 1 on Q2. If you notice change in the cathode word is done during displays are turned off and there is no delay between turning off and turning on steps. Human eyes persist the vision for a duration of 1/25th of a second, so complete the cycle of displaying values in all segments before 1/25th of a second to avoid flickering.