As shown above, there are two types of 7 segment displays, common cathode and common anode. Both of them produce the same results, it is just how you operate them.
Generally people do prefer the common cathode because sending a logic ‘1’ will light the LED up while sending a logic ‘0’ will turn the LED off. That is the standard convention. The common anode is the other way around.
So I thought I will get myself the common cathode version to make things simpler, so I went to the shop and bought it. When I came back, I tried to light it up but it just won’t light up, I thought maybe I got a defective unit. When I’m about the give up, I tried reversing the polarity and it lit up. The seller gave me the wrong type. If Jalan Pasar is near I won’t hesitate to go and exchange it for a correct version but it’s not. It’s not worth it to go all the way just for a RM1.50 part. Well, since I have not tried using current sinking on a MCU before, why not right. (A MCU output can either be current-sourcing or current-sinking, current-sourcing means that the pin will provide positive voltage while current-sinking means that the output pin can act as a ground, receiving current). This also means that now to turn on the LED I must program the MCU to send a logic ‘0’.
I connect the 7 segment display to the PIC16F84A and wrote a corresponding look-up table.
The 7 segment display will display a different number every time the push button is pressed.
A 10ms debouncing is implemented to avoid any logic corruption. The 10ms delay is calculated using the program that I wrote. To find it, click here →.
Here is a video of the 7 segment display in action.
Sorry again for the poor video quality. The video looked fine before I uploaded it to vimeo. I shall try and see how I can improve the quality.