ATTiny Capsense Light Switch Project

Hey guys.. yeah, it’s been freaking forever since I posted last. I really should post more often. Anyways, my latest project was a bit of a home improvement project. Almost a year in the making, really. I installed some LED strip lighting around the top of my living room. I happen to have a room that has some nice molding going around the room which made a perfect place to install 20 meters of white LED strip lights.I’ve got a few dead Xbox 360’s, so I grabbed the power supply from one of them. It puts out a nice 5v standby (constant) power, and a switched 12v power. Originally I had simply wired up a toggle switch, but just having a toggle switch at the end of some wires on my desk was ugly, annoying, and the wires kept breaking at the solder joint.

I’d always wanted to wire up an ATTiny and use the cap sense library to toggle the lights. So here are some details on how I did it.

2013-11-24 11.22.58

That’s the power jack at the end of the XBox360 power supply cord. I desoldered the jack from one of my dead XBox360’s. Yes, it’s very hard to desolder it. I have a hot air rework station, as well as a desoldering iron. I used both at the same time. I found the pinout online to determine which pin did what.

2013-11-24 11.22.13

It’s a bit out of focus, but this is what I built. It’s an ATTiny85 in a socket, with a 750,000 ohm resistor next to it. Heh, brutally simple. Gotta love it. I used some basic perf board I had laying around. It’s got 4 wires coming from the chip, power, ground, one wire for the cap sense, and an output to the trigger wire that turns on the power supply. When that ATTiny pin goes HIGH, the power supply comes on.

2013-11-24 11.22.222013-11-24 11.22.17

I wanted something like a metal “knick-knack” or figurine, or something inconspicuous I could set on the desk to use as my “switch”. I recently picked up a stylus for my iPad, and it came with spare tips in this tin, so I had this tin sitting under the monitor. It’s a pretty nice looking tin, and it seemed like the perfect thing to use. Using a very large butane powered soldering iron, I was able to solder a wire to the side of it. The wire runs back to the ATTiny on the input side of the 750k ohm resistor.

2013-11-24 11.29.35

There it is, back next to my monitor, like nothing has changed. The foot of the monitor sits on the wire, which keeps it stuck in place very nicely.

Here’s some video of the device in action. You can see I just kind of tossed the circuit back behind my desk. I still need to put some wire conduit covering over the wire heading up the wall. That’s been on my to-do list for a year as well.

And finally, below, you’ll find the sketch running on the ATTiny:

Really just took the example sketch that came with the cap sense library and added a couple lines to it, tossed out a bunch of the excess, and it runs great. I wasn’t totally sure it’d work on an ATTiny, it does. I used an Arduino Uno to prototype the circuit and perfect the sketch.

If you plan to do this yourself, keep in mind you’ll need to install the ATTiny extensions into the Arduino hardware folder in your sketch folder, in order to add support for the ATTiny.

© Una 2011