Saturday, 11 February 2012

30. Christmas Lights with Transistors

A component I haven't used yet: The Transistor.

I had some battery operated Christmas lights. They were static, always on, with red, green, orange and blue LEDs.

I wondered if I could make them flash. As it turns out they were wired into two groups, red/orange and green/blue. At one end they were connect all together at the positive terminal and at the other end they two groups each connected to a resistor and the negative terminal. As this was all wound up in plastic sheath I would probably have damaged it trying to separate all the wires, so I left it as it was and went with the two grouped colours.

Now as the red/orange and green/blue were connect to the negative terminal via a resistor each, this meant they were outputs, that is +5---LED---Resistor---GND.

In order to program a PIC chip to control them I needed an input. This was not going to work, so I figured I could use an NPN Transistor to act as a switch.

I programmed a PIC12F508 to connect to pins to two transistors to switch the LEDs on and off. I also incorporated a 4-gang DIP switch to allow 16 flashing modes. I ended up just having Switch 1 as a fast/slow option, switches 2 & 3 to give 4 flashing modes and switch 4 enables the original static always on mode.

Here's my breadboard layout before I soldered it all together and put it into battery compartment and put a USB cable to provide +5V power instead of 4.5V with batteries.

1 comment:

  1. I'm glad that there's someone on earth that thinks like me, having done a similar thing last Christmas.

    I fitted a Veroboard Arduino clone I built the summer before in the base of a cheap fibre-optic Xmas tree. I ripped out the (dodgy) mains electrics, servo-taped everything down and wired a big RGB LED to 3 of the Arduino's outputs, placing it where the lamp should have been.

    Hey presto, one fully programmable Christmas tree, and one withering look from my wife.

    ReplyDelete