Power Pic RGB Infrared for PIC 16F628



The latest evlution of Power Pic RGB with Infrared remote control is for PIC 16F628 lovers. In short, it generates colors using a RGB LED, can be controlled using any infrared remote controller compatible with the Sony® Sirc code and has two auxiliary buttons for easy control even without the remote controller.

This circuit is the fourth and final evolution of the Pic RGB project [3] in which the goal was to control a RGB LED and randomly generate colors. 


Design and Implementation

The microcontroller is now a PIC 16F628 and as before a pin with the Interrupt on Change feature is required to receive the infrared signals. There are now two buttons to control the circuit without the remote controller.


As in the previous project, the infrared remote controller can be a cheap chinese universal remote controller capable of emititng Sony SIRC.

The physical buttons have two functions each. Button 1 is the power button. When a short pulse is applied it will turn the LED on and off. Button 2 selects the working mode, also when a short pulse is applied.

When a long pulse is applied to any of the two buttons, they will change the selected color, much like PR+ and PR- on the remote controller. Each button rotates the HUE in the oposite direction of each other.



The schematic is similar in some aspects to the previous incarnations but the pins of the PIC driving the LED and the TSOP receiver are totally different as one would expect because a different PIC is used.

From left to right we have the power supply based on a 7805 5V 1A regulator, below the power supply are three mosfets that will drive the LED, the microcontroller in the middle, below the TSOP1738 to receive the infrared signals and finaly on the right are the two buttons. Click the image to enlarge.

Each mosfet can drive a maximum 600mA through its drain but according to Prolight each LED (red, green and blue) can only sustain 300mA which makes this mosfet perfect for the job.

Summing the 3 LED currents we get 900mA not counting the current consumed by the 7805 and the PIC itself which should around  3 or 4 mA. The 7805 is able to supply 1A of current with a proper heatsink.

The TSOP1738 infrared receiver can be replaced with any model like TSOP1238, TSOP31238, SFH5110, etc. as long as the receiving frequency is between 38Khz and 40Khz. Ideally it should be 38Khz. R5 and C4 perform some filtering on the TSOP1738 supply voltage and R4 is a pull-up to maintain GP1 at 5V when no signal is being received.

List of Components

Amount Part Description
1 D1 1N4001 Rectifier diode or similar
1 C1 2200uF/25V capacitor
1 C3 100nF capacitor
1 C2 470uF/10V capacitor
1 C4 4.7uF/10V capacitor
1 IC2 7805 regulator
1 IC1 PIC 16F628
1 IR1 TSOP1738 or similar 38Khz, 3 pin infrared receiver
3 Q1,Q2,Q3 BS170 mosfet
1 R5 100 Ohm resistor
1 R4

10k resistor

1 R6

4k7 resistor

1 R3 5.6 Ohm/1W resistor
2 R1,R2 22 Ohm 1/4W resistor
1 R7 1 KOhm 1/4W resistor
3 R11,R12,R13 100 KOhm resistors
1 LED2 3 mm LED (any color is ok)
1 J1 Molex 4 pin male 90 degrees PCB connector
1 J1 cap Molex 4 pin female
1 J2 Power connector for PCB
4 - wires to connect the molex to the LED
1 LED Prolight 3W RGB LED with common anode
1 - Heat sink for the LED or some aluminum piece large enough to remove the heat
1 - TO-220 Heat sink for the 7805 regulator
1 - AC/DC power supply capable of delivering 1A
("wall wart" or similar)
2 S1,S2 Push buttons normally open
1 - Solderless white board to mount everything on



I didn't make a PCB for this project because I didn't have the need for it. The main reason for this project was to deliver a new software version for both pic12f and 16f families.

You can download the schematic in eagle format at the downloads section along with the software.



The software is written in C and consists of a triple PWM modulator, a SIRC decoder and a HSV to RGB converter.

The PWM modulator and the SIRC decoder are designed as device drivers and are fully interrupt driven. This way the main loop of the program is dedicated to do the remaining task of deciding what to do with the decoded infrared buttons and physical buttons.

hsvInstead of giving the user direct control over the RGB value on the LEDs, the software implements the HSV color space in order to navigate along the full color spectrum. The HSV color space [2] can be perceived as a cone where each component represents the following:

Using the HSV color space gives the user the ability to navigate along the color spectrum just by increasing or decreasing Hue. Adjusting Saturation and Value refines the selected color. This is a lot easier than asking the user to select the Red, Green and Blue components independently. As an example, imagining the user wants a light blue color, he/she should change the Hue until the color is near blue and then decrease saturation a little, until the light blue pleases him/her.


The software includes three different working modes:

The status LED pulses whenever a valid remote controller code is received and when the circuit changes its working mode. When entering Fixed mode it will produce 1 pulse (much more visible than the IR pulses), Rotation mode will produce 2 pulses and Random mode 3 pulses and staying lit.

Button 0 of the remote controller allows to change in sequence between those three modes. Physical button 2 does the same (short click).



The software works quite nicely in random mode and calls one's attention when the current active color and the new randomly selected color are far apart in the HUE circunference because it will produce a quick desaturation of the current color and resaturate into the new color. Colors not too far apart will simply change with the rotation method used in Rotation mode but much faster.



Files available for download:

Firmware includes source code.


  1. Power Pic RGB with infrared remote control
  2. Power Pic RGB
  3. Pic RGB
  4. HSL and HSV definitions by Wikipedia
  5. Adventures in HSV Space, July 2001, Darrin Cardani (local copy)


Published on Wednesday 2012/11/28, last modified on Sunday 2013/04/28