LED Chaser for PIC16F84A and PIC16F628A
Fully commented source code and programmer ready HEX files are provided for the PIC 16F84A and 16F628A at the bottom of this page.
The circuit has been constructed on a PCB but can easily be built on strip-board, or a solderless breadboard.
This project has been put together for anyone starting with their first PIC and the source code is heavily commented with references to the PIC datasheets and the MPASM assembler user guide.
Although the PIC 16F84A is really obsolete and I wouldn’t normally do a project using it, this chip is used extensively throughout education and for many people this will still be their first step into the world of PICs. I’ve also written a version for the PIC16F628A which is a pin compatible replacement for the 16F84A and I would recommend that if you intend to develop your interest in PIC microcontrollers you start using this device rather than the 16F84A.
Please note that the 16F84 and 16F628 without the ‘A’ suffixare not suitable for this project. You must use the 16F84A or 16F628A parts.
The heart of the LED chaser is the PIC microcontroller, IC1. This can be either a PIC16F84A or PIC16F628A as software code is provided for either device. The program that runs on this chip controls the LEDs attached to the output port pins. Resistors R1 thru R12 limit the current through LED1 – LED12 to a safe level that won’t damage the PICs I/O ports or LEDs.
The value of the resistors has been selected to be safe rather provide maximum brightness. If you decide to use high brightness blue, green or white 5mm LEDs you may need to change these from 270ohms to 100ohms. For all other 5mm LEDs the 270ohm resistors will be fine.
Crystal Q1 and capacitors C1 and C2 connect to the oscillator circuit inside the PIC. This generate a stable 4Mhz clock which is used by the PIC to control the timing of the microcontroller core. If you are using the PIC 16F628A you can omit these three components and use the PICs internal RC oscillator. However, you will also need to make a change to the source code before programming the PIC so it knows to use it’s internal oscillator. (see here)
Capacitor C3 is used to decouple the 5 volt power supply rail. If you are building the circuit on a breadboard or stripboard you should ensure it is located close to the PICs Vdd connection (pin 14 ).
The input voltage can be anywhere form 9 to 12 volts but the PIC requires a precisely controlled 5 volt supply. This is provided by IC2, a 78M05 3-terminal 5 volt regulator. Capacitor C4 decouples the input to the regulator. Diode D1 protects the circuit from accidental reverse polarity of the input voltage.
You can buy all the parts needed to build this project from most component suppliers world wide. In the UK you can get everything from Rapid Online and I’ve included a parts list with their part numbers below.
For more detail: LED Chaser for PIC16F84A and PIC16F628A
EasyEDA: Ideas for Circuit Design, Innovation for Electronics Access
Free Circuit Design: Schematic – Simulation – PCB Layout – Gerber Viewer
Cheapest PCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 24 hours Quick Turn, DHL Delivery in 3 Days
Current Project / Post can also be found using:
- 12 channel led chaser with pic16f84a circuit
- 12 channel led chaser with pic16f84a circuit diagram
- led chaser pic16f84a
- pic16f628a microcontroller led chaser