Monday, February 25, 2013

RGB LED software PWM fader using 12f675 - part 2

One of first program for learning microcontrollers is to blink a LED. This is considered as the "Hello World" version of hardware program. The basic concept is to make the pins as output and then make them high or low alternatively.

When you have learned the first program you would like move to more complex programming. A fader to fade-in and fade-out an LED would be a perfect next step. Here's the schematic to create a fader which uses a single RGB LED to create a rainbow effect for colors with a cheap PIC12F675 8 pin microcontroller.

Schematic

As you would have noticed that the circuit uses very few components. Now here is the flow chart for concept,
The program would start by setting up counters for all the LEDs and keep reducing the currently ON LED and increasing the counter for the next LED. While at the same time it switches on and off the LEDs based on the counter as delay. When the counter for current LED becomes zero it moves to the next LED.

Flowchart of the program,

Download the code in HITECH C from here.

This is how the it looks on the testboard.



No comments:

Post a Comment