8 Channel PWM LED Chaser for PIC16F628A

Summary of 8 Channel PWM LED Chaser for PIC16F628A


This article describes an 8-channel LED chaser circuit driven by a PIC16F628A microcontroller. It features variable chase speeds, three run modes (sequential, random, manual), and PWM intensity control with four levels. The design supports mixed LEDs, includes in-circuit programming (ICSP), and is suitable for teaching or model effects. A pre-written firmware option is available for users who prefer not to code.

Parts used in the 8 Channel PWM LED Chaser:

  • PIC 16F628A microcontroller
  • 7805 3-terminal 5 volt regulator
  • LEDs (up to 8)
  • Current limiting resistors (R1-R8, R25, R26)
  • Mode control switch (S1)
  • In-circuit programming header (ICSP)
  • Decoupling capacitor (C2)
  • Stabilizing capacitors (C1)
  • Protection diodes (D1, D14)
  • 3-way terminal block
  • Header plug K1

Description

Update: Variable chase speed option kit now available (see here for details)

This neat little circuit provides 8 LEDs directly driven from the PIC along with a single mode control switch.  The firmware elsewhere on this page drives the LEDs with a 5 bit PWM signal providing each of the 8 LED channels with four levels of intensity; off, dim, mid, bright.  A number of sequences are programmed into the firmware to provide some interesting visual effects and chase sequences, including the classic effect seen on the car in the Knight Rider TV series. 

The software has sequential, random and manual sequence run modes and manual advance to the next sequence in any mode.  The selected sequence and mode are also saved to non-volatile memory so it will always restart in the selected mode.

The design is deliberately simple with each LED being directly driven from a PIC I/O pin.  This and the inclusion of an in-circuit programming header (ICSP) make the circuit ideal for teaching/learning introductory PIC assembly language programming.

You can use it with different sized LEDs and mixed colours, as well as fewer than 8 LEDs.  As well as using it as a LED chaser it is great for adding effects to toys and models.  See FAQ

However, if you just want a cool LED chaser without having to write any code, a ready written LED chaser program including 34 chase effects with source code and programmer ready HEX files is provided 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.

PWM LED Chaser

Need a board that can drive more LEDs?  check out the Power MOSFET Chaser Project

Download schematic in PDF

Circuit Description

The heart of the LED chaser is the PIC 16F628A microcontroller, IC2. The program that runs on this chip controls the LEDs attached to the output port pins.  Resistors R1 thru R8 limit the current through LED1 – LED8 to a safe level that won’t damage the PICs I/O ports or LEDs.  The LEDs can either be mounted on the PCB or via header plug K1 and a ribbon cable which permits the LEDs to be mounted in a different arrangement, location etc.  If the LEDs are connected via the K1 header, don’t install LEDs on the PCB, it’s either or but not both.

Resistor R25 provides a pull-up for the input connected to switch S1.  R26 pulls up the PIC’s MCLR reset signal during normal operation while allowing the input to be raised to 12.5 volts during in-circuit programming.  The ICSP header provides connection for an ICSP programmer such as a PICkit2 making it easy to reprogram the PIC without removing it from the PCB.

Capacitor C2 is used to decouple the 5 volt power supply to the PIC.  If you’re building the circuit on a breadboard or stripboard you should ensure it is located close to the PICs Vdd connection (pin 14 ).

Power is supplied to the circuit through the 3-way terminal block and must be smooth DC between 9 and 18 volts.  The PIC requires a precisely controlled 5 volt supply and this is provided by IC1, a 7805 3-terminal, 5 volt regulator.  Typical current drawn by the circuit with all LEDs on is only around 100mA so the voltage regulator doesn’t require any additional heatsink. Capacitors C1 stabilize the regulator.  Diode D1 protects the circuit from accidental reverse polarity of the input voltage.  Diode D14 protects the regulator and is only really needed if you will be using the ICSP feature (doesn’t hurt to fit it anyway)

Additional information about PCB480C

Notes:

  • The latest high brightness LEDs are very bright even with 330R current limiting resistors. However, if you do need to change these resistors for some reason take into account the maximum current that the PIC can source from an I/O port pin is 25mA, and also be aware that the output voltage will drop as you increase the load. Ideally keep the current per output under 15mA
  • If you install LEDs that require a lower value series resistor you may find you are unable to program the PIC in-circuit via the ICSP header.  This is because the I/O port pins on the PIC that are used for In-Circuit Serial Programming are shared with the LEDs.  The programmer may be unable to drive these lines when lower value resistor are used.  With the 330R resistors and PICKit2 programmer, In-Circuit programming should work without problems.
  • The ICSP header allows programming of the PIC while installed in the circuit.  It is only required if you intend to connect a programmer to modify the sequences or code.  It is not supplied with the kit but is available as an option.

 

For more detail: 8 Channel PWM LED Chaser for PIC16F628A

Quick Solutions to Questions related to 8 Channel PWM LED Chaser:

  • How does the circuit drive the LEDs?
    The circuit drives 8 LEDs directly from PIC I/O pins using a 5 bit PWM signal to provide four intensity levels.
  • Can I use different colored LEDs?
    Yes, you can use different sized LEDs and mixed colours, as well as fewer than 8 LEDs.
  • What voltage range powers the circuit?
    Power must be supplied via a 3-way terminal block as smooth DC between 9 and 18 volts.
  • Does the device save my settings?
    Yes, the selected sequence and mode are saved to non-volatile memory so it restarts in the selected mode.
  • How do I program the chip without removing it?
    You can use the ICSP header with a programmer like a PICkit2 to reprogram the PIC while installed.
  • What is the maximum current per output pin?
    The maximum current a PIC can source from an I/O port pin is 25mA, though keeping it under 15mA is ideal.
  • Why might in-circuit programming fail?
    Installing LEDs with lower value series resistors may prevent in-circuit programming because the lines are shared with the LEDs.
  • Is a heatsink needed for the voltage regulator?
    No, typical current draw is around 100mA, so the voltage regulator does not require an additional heatsink.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter