Introduction: BlinkLED



A BlinkLED is a LED that has its own PIC microcontroller. Blink patterns and blink rates are programmable and BlinkLEDs can be used individually (for LED Throwies) or in strings for holiday or special lighting.

I made these because I wanted to trim my Christmas tree with individual blinking lights. With the BlinkLED, I can do that easily and safely. The BlinkLED daisy chains with 2 thin nearly invisible wires (#30 AWG wire wrap wire) and runs from a  3 - 5 volt dc power supply or battery so no high voltage (120 vac) wiring is required. The video shows BlinkLEDs that blink and change color alternating between red and green. The time each BlinkLED remains in one color is randomly determined.

So that there are no surprises later, you will have to have electronic assembly skills and equipment to program PIC microcontrollers.

Step 1: Choose the Components

For each BlinkLED, you will need the following:

1 ea Microchip 12F509 PIC Microcontroller (Mouser PN 579-PIC12F509-I/P)

1 ea 22 ohm, 1/4 watt resistor (Mouser PN 291-22-RC). I used a 22 ohm resistor in my prototype but any value between 22 and 220 ohms will work. It depends on the supply voltage you will be using, the voltage drop across the LED, and the forward voltage of the LED. You want to choose a value that will result in a current of 10 to 20 milliamps through the LED. As a rule of thumb, resistor value in ohms equals the supply voltage minus .5 volts minus the voltage drop of the LED divided by the LED current in amperes (1 milliampere = .001 ampere). For example, for a green LED which typically has a 2.2 voltage drop with a 3.2 volt power supply: R = (3.2 volts -.5 volts -2.2 volts) / .020 amps = 25 ohms.

Keep in mind that different colored LED have different voltage drops across them when lite. Typical values are: Green 2.2 volts, Yellow 2.1 volts, Red 2.0 volts, Blue 3.8 volts, and White 3.2 volts. You will have to increase the supply voltage when using Blue and/or White LEDs in order to drive them to full brightness.

1 ea LED. Just about any LED will work. For my prototype, I chose a green LED removed from a Christmas light string. These have a wide viewing angle because of the flat concave top.

Step 2: Assemble Your BlinkLED

Follow the pictures to assemble your BlinkLED. I used a small soldering iron and a vise to hold the PIC. Note the orientation of the notch when making the first solder joint. The resistor is soldered to pin 8 of the PIC. Save the solid wire trimmed from the resistor and solder it to the PIC in the last step. Your finished BlinkLED will have two free leads for connecting power (plus [+] to pin 1 [Vdd] and minus [-] to pin 8 [Vss], the pin with the resistor).

Step 3: Program the PIC

Here is my PICBasic Pro test program. It pulses the LED on for 35 ms and keeps it off for a variable time determined by the RANDOM function. You can modify this program to get the BlinkLED to blink anyway you wish.

'******************************************************
'Program Name: BlinkLED
'Filename: BlinkLED
'Version: v1.00
'******************************************************
'
'DESCRIPTION OF PROGRAM ++++++++++++++++++++++++++++++++
'
'Description/Function: Low cost LED blinker
'
'Compiler and Version: PICBasic PRo v2.5
'
'PIC HARDWARE SETUP +++++++++++++++++++++++++++++++++++
'
'Written for PIC: PIC12F509
'
DEFINE OSC 4
TRISIO = %000000      'Set all pins as outputs
'
LED  var PORTB.5
Delay   VAR WORD
'
'MAIN PROGRAM +++++++++++++++++++++++++++++++++++++++++
Main:

HIGH LED
PAUSE 35
LOW LED

RANDOM Delay
PAUSE Delay & %0000001111111111  'fast
'PAUSE Delay & %0000011111111111  'slow

GOTO Main

END

'################# END OF PROGRAM #####################

To test your BlinkLED, compile, program and run your PIC. When you are happy with the results, remove the BlinkLED from the test board and connect it to a power supply or battery.

Attach a CR2032 battery and BlinkLED makes a nice LED Throwie that will blink for 1-2 weeks continously.

You can fabricate your BlinkLED's as shown or as you can see in the video, I eventually made a PCB to reduce the size of each BlinkLED and added header pins to make it easier to daisy chain units. Also notice I added a power bypass capacitor (.1 mf, 50 volt) and changed the PIC to the lower cost PIC10F202 microcontroller. I used a surface mounted 51 ohm resistor and solder pads for the LED. While designing the PCB, I decided to add a second set of pads on the back side of the PCB. These extra pads allow adding a second LED to produce the two color effect (red to green to red) shown in the Christmas Tree Demo video. (In the next step, I'll show you how to build these using the PIC12F509.)

I interconnect the BlinkLEDs with #30 AWG wire wrap wire. Since all BlinkLEDs are wired in parallel, I am not limited to serial light strings but can have "branch" strings off of a "trunk" string.

Step 4: Making the Red/Green BlinkLED With the PIC12F509

Follow these steps to make the red/green BlinkLED using the PIC12F509. I used 3mm red and green LEDs The polarity of the LEDs is important so follow the steps carefully.

Because the two LED are electrically connected across the power source, they will both light up simultaneously if the voltage is too high. The actual voltage is dependent on the LEDs you use. If this happens use a lower supply voltage. For my BlinkLEDs, a voltage between 3.2 and 4.5 volts worked very well.



Here is my code. The time the BlinkLED is red or green is determined by the RANDOM function.

'PROGRAM INITIALIZATION +++++++++++++++++++++++++++++++
'Green led on comp side, red led on non-comp side
'Steady green, blink grn/red to red, then back

HIGH LED   'led mounted on non comp side

'MAIN PROGRAM +++++++++++++++++++++++++++++++++++++++++
Main:

RANDOM Delay

'PAUSE Delay & %000011111000  'fast
'PAUSE Delay & %001111100000  'medium
'PAUSE Delay & %111110000000  'slow
PAUSE Delay & %1111100000000  'very slow
'PAUSE Delay & %1110000000000  'very slow, less variation
TOGGLE LED
PAUSE 50
TOGGLE LED
PAUSE 50
TOGGLE LED
PAUSE 50
TOGGLE LED
PAUSE 50
TOGGLE LED
PAUSE 50
TOGGLE LED
PAUSE 50
TOGGLE LED

GOTO Main
END

'################# END OF PROGRAM #####################

Have fun!