EDIT: I made another one of these, and hacked an ikea lamp with it. You can see the 'ible overe HERE

The Problem

It is late night, and your cellphone rings. You can't see where it is, you blindly grope around your nightstand, trying in vain to find that illusive switch that will illuminate your side of the bed. You clumsily turn on the lamp, locate your cellphone...and you miss the call. Damn. If only your light was easier to turn on.

The solution

What if all you had to do to turn on your lamp...was to touch anywhere metal on your bedside table? That sounds complicated though, and I AM a strong believer in keeping things simple whenever possible. I wonder if there are any open-source solutions that would allow such a thing to happen? Enter ARDUINO. A cheap, easy to use micro-controller that is dead simple to program and implement.  This sounds like it might just work!

Since I am inherently thrifty (an HVAC-R apprentice, AND a Mennonite) I don't want to commit my only $35 arduino board to the project. This means i'll have to build my own Arduino, which will save me some money.  Additionally, I'm only using a couple of pins, and not doing any serial communications, so I really don't want to bother using an external oscillator. That means I'll have to figure out how to enable the internal oscillator on an atmega 168.


This 'ible will show you how to do the following (without a lot of hand-holding);

How to burn a bootloader to a standalone atmega168 using an Arduino UNO SMD edition.
How to enable the internal oscillator, so you can save $0.50 and not use a crystal.
How to program a standalone chip using an Arduino board and the Arduino IDE.
How capacitive touch objects work.

What is NOT covered
How to read a schematic diagram
How to solder
How to layout a protoboard

Since there are literally hundred of guides on how to solder, how to use schematic diagrams, and basics of digital electronics...I'm not going to go there. You'll notice that there is a search bar in the upper right hand corner of this wonderful site. I'm sure if you try using it, you'll find what you need. That said, if you are having troubles implementing THIS particular project, and it doesn't involve such things as "How do I solder a resistor" then please feel free to ask.

I am curmudgeonly, so my responses to questions that are not included in the scope of this 'ible may or may not include some lighthearted mocking. You have been warned.

This is a proof of concept i'd put together before building the standalone.


Step 1: Materials

- An arduino (I'm using an Arduino Uno SMD, which brings a set of challenges)
- An LED Strip
- Either a mosfet and transistor that your arduino can switch or a small DC Solid State Relay (SSR)
- Atmega168 DIP
- (1) 10k resistor
- (1) 1M resistor
- (1) 16 mHz crystal (might not be required)
- (1) solderless breadboard
- (1) protoboard/strip board.
- Wire
- Wire Nuts
- Wire Strippers, screwdrivers.
- Nuts and bolts
- Small electrical junction box
- (1) power supply that can supply both 12V and 5V. (Or 12V only, and use an 1805IC with a couple of capacitors to smooth it out) 

The total cost on the project was about $20-$30. The most expensive part of the project was the electrical junction box and lid, which came to about $6.00. Home Despot is such a rip-off.

I troll ebay looking for electrical componenet from Thailand. There are some vendors that offer free shipping on a lot of stuff. The SSR I am using was $3 with free shipping. Same goes with the protoboard, get it for cheap on ebay.

The total cost on the project was about $20-$30.
&quot;This is most likely a stupid question, but how does the intensity of the LED change when it's getting 12 volts straight from the power supply?&quot; <br> <br>This isn't a stupid question at all. I believe I touched briefly in a previous section about PWM, but I might be mistaken. PWM stands for pulse width modulation. PWM allows you to vary the duty cycle of a digital pin. This means that you are switching the digital pin on and off very rapidly. This rapid switching results in a decrease in brightness. If you look at the following code <br> <br> if (mode == 0) targetBrightness = 0; <br> if (mode == 1) targetBrightness = 255; <br> if (mode == 2) targetBrightness = 128; <br> if (mode == 3) targetBrightness = 64; <br> <br>targetBrightness = 0; means off. <br>255 is a 100% duty cycle. 128(half of 256) is a 50% duty cycle, 64 (1/4 of 256) is a 25% duty cycle. <br> <br>The value vary between 0 and 255 because the atmega has 16bit address bus, allowing for 2^16 (256) bits. <br> <br>A 50% duty cycle refers to the fact that the LED (or digital output pin) is HIGH (or turned on) for 50% of the time. This means that in a period of 1 second, the light is off for a total of 0.5 sec and on for a total of 1 second. <br> <br>http://d32zx1or0t1x0y.cloudfront.net/2011/06/atmega168a_pwm_02_lrg.jpg This is a nice picture that graphically shows what different duty cycles look like. Notice how the pulse width size changes between the different duty cycles. Modulation means to change something. <br> <br> <br> <br>What this means is
**EDIT: On for 0.5 second, off for 0.5 second in the last paragraph.
<p>You made a simple project over-complicated! It is just a capacitive sensor, and the project is in the Arduino starter kit lessons. One doesn't even need to bootload a separate Atmega168 chip to do that, just use the Arduino uno, or any smaller Arduino boards. I know that it can save cost and space, but these are not necessary steps to make a capacitive sensor. </p>
<p>It works as described in the post. Thank you for sharing with us!</p>
<p>I forgot to mention, I used an N-channel MOSFET, instead of the SSR to drive the LEDs. The only difference is that I had to add a 10k resistor between Grid and ground.</p>
Hey! Awesome ible but the name is a tad misleading. Cap Touch uses changing time constants because of an approaching ground (person) to detect touch without contacting any metal. This uses a resistor to pull high then the human to directly pull to ground. I really enjoyed reading the Instructable but wanted to mention that.
<p>Being curmudgeonly myself, I was tempted to correct your 'ible' to 'able', but - funkit, if we spent our time correcting silly grammar we wouldn't have time to make cool stuff :)</p><p>Good 'able, btw ;) I have about 50x $3 Arduino Nanos hanging around and a box full of addressable LEDs - this will come in handy for gesture switching.</p>
Hi Timbit1985, fantastic project! <br> <br>another crazy question: <br> <br>Can I use an ATmega328P chip instead of the ATmega168 chip for use in this project <br>using : Tools/Board/LilyPad Arduino w/ ATmega328 ? <br> <br>
Did you end up using the ATmega328P ? Did it work out okay for you?
<p>Yes, it worked out perfectly! Will attempt using an Attiny 85. Thx again.</p>
I don't see why not. I believe the lilypad with atmega328 uses an oscillator, where as I chose a firmware that does not. This means that you will have to install a crystal for it to work. Make sure that the pin outs are the same on the atmega328 vs the 168.
<p>Oh thats a realy nice instructable. I was looking for something like this since a long time. Well done!! </p><p>I <br> have one question about this. I have a Arduino Duemilanove which i <br>dont need anymore and I have enough Place to place it in my Lamp. Can i <br>upload your skatch and it will work to? Just to skip the Step for <br>programming the Standalone Chip. </p>
<p>Oops, sorry I missed this. I don't see why it wouldn't work. Good luck! Thanks for checking out my instructables. </p>
<p>It works perfektly ;) thank you again! </p>
Yes, it worked out. Awesome!
That is a good explain and release my problem.Thank You!
I don't understand how to set control the vary with level of LED in the circuit . I only saw a relay with 12V contact direct connect to LED only.
The relay is actually an SSR, which has a very rapid switching rate compared to a mechanical relay. You could use a mosfet as well, which would be cheaper. I just used what I had on hand. <br> <br>Basically the microcontroller turns the SSR on and off rapidly, which in turn switches the LED on and off rapidly. This rapid switching is known as Pulse Width Modulation (PWM), and is a very common way of controlling LED brightness without varying the current or voltage.
This is most likely a stupid question, but how does the intensity of the LED change when it's getting 12 volts straight from the power supply?
Nice work man i appreciate it Very well done!
Nice work man i appreciate it Very well done!
...Can't you just look for the light from your cell phone's screen?
you COULD if the cellphone was in sight. I always keep it in my pants, so I don't forget it when I leave the house.
Fair enough. This is still a good Instructable though.
Thanks. I appreciate the comments.
This is a great project - very similar to one I did a while back except I didn't use Arduino at all (primarily because it's unnecessary overhead). Although I used a constant current driver, a simple MOSFET switch is&nbsp;sufficient&nbsp;in controlling the brightness through PWM.<br> <br> <a href="https://www.instructables.com/id/Custom-LED-Touch-Light-Fixture/" rel="nofollow">https://www.instructables.com/id/Custom-LED-Touch-Light-Fixture/</a><br> <br> The only thing I would really recommend is that you try to use a smaller chip than the ATmega168 - kind of a huge waste of pins and program space (and money) to just read a sensor and turn on/off some lights! I did my whole project with the 8 pin ATtiny25 and still had a few pins and a lot of space left over, but this is the smallest chip that isn't surface mount.<br> <br> For Light Diffusion:<br> Try arranging your LED strip(s) in various shapes and angles and placing the light inside a real light fixture or lamp shade.<br> <br> <br>
Thanks Kurt. I used what I had on hand, which was the atmega168 ;) I have a bunch of attiny85's on the way, which I actually plan on switching into this project once they arrive. <br> <br>That's a good idea regarding the light fixture. I did the same thing inside of my car.
You got my vote! Nice thinking.
Thank you very much :) I am always trying to come up with little ideas to make my wife's life a bit easier.
That's sweet. Make to check out my instructables. B-)
<blockquote> <p> ***WARNING*** I am curmudgeonly, so my responses to questions that are not included in the scope of this 'ible may or may not include some lighthearted mocking. You have been warned.</p> </blockquote> <p> Ha!<br /> <br /> This is an excellent idea, too. Awesome job!</p>
Thanks! I'm glad you like it :)

About This Instructable




Bio: Everywhere I go, there I am.
More by timbit1985:How to grow wild mushrooms mycelium from spores (experimental) Perfectly Simple Pork Tenderloin (Sous-Vide) Rapid motor sheave/pulley removal (HVAC) 
Add instructable to: