In this tutorial we are going to design a 0-99 counter by interfacing two seven segment displays to ATMEGA32A Microcontroller. Here we count events based on number of times button is pressed.
Before moving ahead, let’s understand what is a seven segment display. A seven segment display got its name from the very fact that it has seven illuminating segments. Each of these segments has an LED (Light Emitting Diode). You can see the pin diagram of a seven segment display in below image.
The LEDs are fabricated in a manner that lighting of each LED is contained to its own segment. The important thing to notice here, the LEDs in any seven segment display are arranged in common anode mode (common positive) or common cathode mode (common negative).
The circuit connection of LEDs in common cathode and common anode is shown in above figure. Here one can observe that, in Common Cathode, the negative terminals of every LED is connected together and brought out as GND. In Common Anode, the positive of every LED is connected together and brought out as VCC. These Common Cathode and Common Anode displays come in very handy while multiplexing several cells together.
Now let’s understand multiplexing. It’s simple a technique used to connect more units in parallel to lessen the pins required, by taking advantage of visual effect. Consider an LED is turning ON and OFF continuously at a rate of 2HZ per second, i.e. it ON two times and OFF two times a second. Now at this rate a human eye can see both ON cycle and OFF cycle. But if frequency is increased to 50HZ, that is 50 ON times and 50 OFF times for the LED in a second. At this rate a human eye cannot see turning OFF cycles at all. This is an effect of vision. At this rate the eye pictures the LED with less brightness and that is all.
Hardware: ATMEGA32, Power supply (5v), AVR-ISP PROGRAMMER, HDSP5503, Seven segment displays (two pieces) (any common cathode will do ), 47uF capacitor (connected across power supply), button(three pieces), 10KΩ resistor (two pieces), 1KΩ resistor, 220Ω resistor (two pieces), 100nF capacitor (three pieces), 2N2222 transistors (two pieces).
Software: Atmel studio 6.1, progisp or flash magic.
The connections which are done for 7 segment display are as follows:
PIN1 or e to PIN (A, 4)
PIN2 or d to PIN (A, 3)
PIN4 or c to PIN (A, 2)
PIN5 or h or DP to PIN (A, 7) /// Not needed as we are not using decimal point
PIN6 or b to PIN (A, 1)
PIN7 or a to PIN (A, 0)
PIN9 or f to PIN (A, 5)
PIN10 or g to PIN (A, 6)
PIN3 or PIN8 or CC to transistor collector
The important thing here is although both segments share same data port to ATMEGA, the Common Cathodes of both displays are connected to two different transistor collectors. Now as of multiplexing, as explained in introduction we are going to turn ON and OFF displays instead of LED.
For more detail: 0-99 Counter using AVR Microcontroller