LEDs are much more efficient than the bulbs in use and will probably never have to be replaced. The decision to make the fixture touch sensitive came from my difficulty in finding a suitable push on-off button in white that can handle larger amounts of current.
Although my design is based on a 12V DC power source, a similar project could be made by using a regulation circuit to convert the AC power in your home to a suitable DC level. Remember, any time you are working with electricity it is VERY important to turn off the power source before you try to connect anything. NEVER work with live voltage lines!
I posted this project on my website a while ago, but I thought it deserved an Instructables makeover! It project involves a bit of complex circuitry design and programming but has been a lot of fun, and if you are ready and willing than so am I! Let's get to it...
Step 1: Gather Your Materials
Drill with various sized bits and and drivers
Needle Nose Pliers
Soldering Iron and Electrical Solder
Hot Glue Gun
Computer - To view Instructable, look at designs, and download program
AVR Programmer - I use the Pocket Programmer from Sparkfun
Multimeter - Always useful when building circuits!
Eagle PCB Designer - for schematic file viewing and editing (Optional)
WinAVR - To install the source code (AVR Studio should also work)
Light Fixture to Convert - Needs to be conductive at the core, but can have a non-conductive coating.
Screws to Mount Fixture - Should come with the fixture
Small bolt and a few nuts - to connect our touch sensor to the fixture
Piece of sturdy cardboard - roughly the size of the fixture
Electrical Components - All available at Digikey
Small Perf Board to solder components - the size depends on your ability to solder and what fits in your fixture
Small Guage Wire for circuit connections - I used gauges 30 and 22
Various Wire Caps for safe connections
Large Guage wire for power and LED connections - I used 10 guage wire
Roll of warm white surface mount LEDs - I found mine on Amazon
1 x AVR ATtinyx5 microcontroller - the "x5" means any uC in that line will work: 15, 25, 45, or 85 [ Datasheet ]
1 x Atmel AT42QT1010 Single Channel Touch Sensor [ Datasheet ]
1 x 8 Pin DIP socket for uC chip
1 x 3.3V regulator (could work on 5V, but I wanted less power consumption) - I used the MCP1702 [ Datasheet ]
1 x Logic Level N Channel Power MOSFET, Must fully turn on at regulated voltage level! - I used the STD50NH02 [ Datasheet ]
1 x NPN Transistor - I used the common 2N3904 [ Datasheet ]
1 x 3 Position Screw Terminal for Power and LED connections
4 x 4001 Rectifier Diode
1 x 100uF Electrolytic Capacitor
1 x 10uF Electrolytic Capacitor
2 x 1uF Electrolytic or Ceramic Capacitor
1 x 0.1uF Ceramic Capacitor
1 x 0.01uF Ceramic Capacitor (Optional)
1 x 47nF Ceramic or Polyester Film Capacitor
7 x 10k Ohm Resistor
1 x 0.33 Ohm Resistor - Must be rated at least 1.5 Watts!!!
Step 2: Circuit Design Overview
The circuit was created in Eagle PCB designer, and I have attached the latest version of the schematic.
I will also cover each of the four circuit sections in more detail in the following steps. If you are not interested in how they work, you can skip to Step 7 to see the complete soldered circuit!
Step 3: Schematic Overview 1 - Power Supply
Step 4: Schematic Overview 2 - Touch Sensor
Step 5: Schematic Overview 3 - Microcontroller
The LED driver is connected to a dedicated hardware timer output, so it's operation is independent of the main processor, but I'll talk more about that in the Step 8 - Source Code.
Step 6: Schematic Overview 4 - LED Driver
The brightness control comes from the pulsing. If a pulse width of 50% is used, than the LEDs will only be on 50% of the time and will appear at about 50% of the total brightness. This is because the human eye has a slower refresh rate than the pulse frequency, and the LED retains some afterglow in its off state. A frequency of 122 Hz was used for the LED pulse.
Step 7: Building the Circuit
The rest of the build was pretty straight forward as long as you know how to solder. The most important thing to remember is that the wires going to and from the LEDs need to be bigger gauge because of the larger current flow. Another important aspect is heat regulation. The MOSFET transistor will get hot sinking this current, even though it is rate for a much larger one. This component cannot be up against other things because it will need plenty of airflow and potentially a heat sink for proper operation. I learned the hard way and had to replace it twice before decided to house that particular component outside of the fixture, but more on that in Step 10 - Completing the Fixture.
I used WinAVR to compile and the USB Pocket Programmer from Sparkfun to download the code into the AVR chip, but you could use AVR Studio and whatever programmer you are used to; just be sure to alter the makefile accordingly. The AVR fuse bits are the default values.
Basically, the uC waits in sleep mode until it is woken up by a hardware interrupt from the touch sensor. It then turns the LEDs on in a low state. When the sensor is touched again, the mode is changed from low to medium, and again to high after another touch. One final touch of the fixture will turn the lights off and put the uC back to sleep, waiting to be woken up by the touch sensor. This cycle repeats itself indefinitely.
Two header files are in use. The first is my custom AVR.h file which contains many useful macros as well as calling other required headers. The second is the sleep.h file that is included with WinAVR.
The program starts by initializing the AVR chip: turning off unused features, setting the I/O ports, reducing the system clock frequency (for more power savings), setting up Timer 0 for a 122 Hz pulse, enabling the pin change interrupt for the touch sensor, and enabling the power down sleep mode.
The program then enters a forever loop which only does one thing: check to see if sleep is enabled. If sleep is enabled, the uC is put to sleep to wait on the touch sensor's hardware interrupt.
Only one interrupt handler is used: the pin change interrupt for the touch sensor. This routine checks the state of the LEDs and decides to turn them on, increase the brightness (pulse width), or turn them off accordingly anytime the fixture is touched. It also holds the program in a loop until the fixture is no longer being touched.
The LED pulse is handled entirely by hardware features of the uC. The only thing that has to be done in the code is to enable or disable the Timer 0 output connected to the LED driver.
Step 9: Preparing the LEDs
The roll of LED strip lights I got was great, but came ready to be used meaning each string of LEDs already had a series resistor. The roll is basically a bunch of 3 LED strings in parallel, so it can be broken up every 3 LEDs. The series resistor in each string needs to be shorted or the current source LED driver won't work correctly. Wait, am I suggesting you alter (or ruin, as my wife would say) a perfectly good roll of LEDs? Why yes, yes I am.
I used 24 strings to provide enough brightness, but your necessary amount of LED strings may increase or decrease. If so, be sure to adjust the value of R3 in Step 6 accordingly to provide the correct amount of current through each string.
I recycled the leads of components I cut off when building the circuit and used small pieces of solid wire when I ran out of cut leads. The traces on the LED strip can be soldered to directly. When that is done, each LED string needs to have a pair of lead wires so they can all be connected in parallel.
Step 10: Completing the Fixture
At this point, the fixture can be mounted in the ceiling. I am assuming there is already a hole with the power leads available. The power can then be connected to the circuit with wire caps.
The next step is to create a housing for the LEDs. I used a piece of sturdy cardboard and bent to wings to force some of the light down at an angle, and lower the LEDs from the circuit. The cardboard was wrapped in alluminum foil to aid in the LED head dissipation and to make it look nicer. Once the wires have all been connected and capped, the LED housing can be attached to the fixture using a few strips of Velcro. This allows it to be easily removed for access to the circuit or to remove the fixture.
Step 11: Heat Considerations
The first time the MOSFET quit, the LEDs flashed a few times, and then remained in a dim state. The fixture was unresponsive, so I took it apart to work on it. I ended up running wire leads to the circuit and attaching a new MOSFET to these leads hoping that the part would get enough air flow raised off of the circuit. But after a few days of running, it too gave up.
This time, I decided to run the MOSFET leads through a small hole I drilled outside of the fixture. The part would still be concealed by the fixture outer rim, but it would be outside of the hot air filled interior and stood a chance of keeping cool. I also affixed it to a large heat sink. This solution has been very effective. The entire fixture has worked flawlessly with this heat dissipation in mind. I also covered the surrounding fixture area with electric tape to prevent the heat sink from touching the fixture and effecting the sensor sensitivity.