In this article, we will show how to drive a 7 segment LED Display using a PIC16F690 microcontroller.
This PIC16F690 microcontroller chip is actually a part of the PIC2 Starter Kit, so we will actually be using this starter kit to drive the LED Display.
A 7 Segment LED Display is an electronic device that contains 8 individual LEDs. Each of the LEDs can either be on or off. Depending on which LEDs are lit determines the character which is displayed. The LED display can show any number from 0 to 9. It can also show many alphabetical characters.
In this project, we will use the PIC16F690 microchip contained in the PIC2 Starter Kit to control the 7 segment LED display so that we can light up whichever segments we want to display whatever characters we want in sequence.
A 7 segment LED display is a valuable electronic device because used in conjunction with other LED displays, it can function as a numerical display, such as time for a clock, a display for a game scoreboard, or any such other numerical display. So it is a very valuable electronic device to know how to operate.
Using a microcontroller to drive an LED display is much more easy and efficient than not. If we did not have a microcontroller to drive an LED, in order to display different numerical values, we would need someone to manually change which turn on or off different LEDs in the LED display. This would be much less efficient than using a microcontroller. When a microcontroller, in this case a PIC16F690 microcontroller, is connected to an LED display, all we need to do to change the software to display different characters. Changing the hardware, which LEDs are lit, is much more complex and time-consuming and, thus, is simply not efficient.
We will now show how to connect and program the PIC16F690 microcontroller to drive an LED display. Specifically, for this circuit, we will drive one LED display, for simplicity, to count from 0 to 0 and then reset back to 0.
Again, a 7 segment LED sipaly is made up of 8 individual LEDs. Thus, the microcontroller needs enough I/O pins to connect to each of the 8 terminals of the 7 segment LED display. It’s the job of the software to light them in the proper order to create the numbers 0 to 9.
For this project, we will use a common anode LED display, which is a display all the anode leads are common and the cathode leads are not. To understand the difference between common anode and common cathode displays, see What is a 7 Segment LED Display.
The schematic of the PIC16F590 microcontroller chip connected to the LED display is shown below:
The PIC16F690 can drive an LED directly from an I/O pin because it can output up to 25ma of current. The whole port can supply 200ma in total maximum. We connect 330Ω resistors to the outputs to limit current so that the LEDs don’t receive too much current and burn out. They are safety current-limiting resistors.
The only connections we need is 5 volts of power to the Vdd pin and to have the Vss pin connected to ground. However, if you plug in the PICkit 2 programmer, you can get power from it and, thus, would not have to make power connections. This reduces more connections.
The PIC16F690 has an internal oscillator that we will run at the default speed of 4MHz. The MCLR master clear reset pin will be set to internal mode so we don’t need any external reset circuitry. Those are both setup in the configuration register of the PIC16F690. We control that configuration in the software.
Being that the LED display is common anode, all the anodes are tied together (are common). The cathodes are separate and tie down to ground. For an LED to have a complete circuit and turn on, the LED needs to connect to ground. This will happen if its cathode terminal is connected to ground. Thus, if an LED segment is connected to ground it is on. This is why an LED turns on if it is low. If the LED is connected only to the anode’s positive voltage, it is HIGH and off. This will be important when coding, because a 0 will represent an ON LED and a 1 will represent an OFF LED.
Code to Drive LED Display
The code need to drive an LED display is written for the HI-TECH PICC PRO compiler. This can be done in lite mode.
This will sequence 0 to 9 at a 1/2 second rate. It is a common anode display driven by PortC.
For more detail: PIC16F690 Microcontroller Circuit- How to Drive an LED Display