Introduction: Sonic Switch: Use a Sonic Screwdriver to Turn on Your Computer!

What it is: An Arduino-based light-sensitive switch for turning on a desktop computer.

Why its cool: Use a Sonic Screwdriver to turn on your computer!

Story: This project started, as I'm sure a lot of them do, as a result of boredom and the thought "Wouldn't it be cool if...". I am a fan of Dr. Who. Enough of a fan, I suppose, to spend money on a plastic replica of the good Doctor's Sonic Screwdriver (http://www.thinkgeek.com/geektoys/cubegoodies/8cff/). It was cheap, and it lights up and makes noise _ As a fan of the show (and a CPE/EE), I simply had to have it.

While pondering what to do with my time off, having recently graduated, and while playing with the Sonic Screwdriver, I had one of those "...Duuuuude, Awesome!" moments. And an hour or so and a transistor or two later, I have a device that allows me to do what you see in the video below:


Step 1: The Nitty Gritty

Now we'll get into the technical stuff.

In a nutshell: The photocell is connected in a voltage divider circuit, resulting in a voltage between 0-5V applied to the analog input pin of the Boarduino depending on the amount of light detected. The on-board ADC gives a numerical value based on this voltage. If that value crosses a certain threshold, the digital pin connected to the Base of the transistor is set high, the motherboard power switch circuit is completed, and the computer turns on (or off).

Yes, the circuit can be triggered by any bright enough light source. Like a normal flashlight or, oh I don't know, a camera flash. But its just so much cooler to whip out a Sonic Screwdriver and be all like the Doctor and stuff...Right? Thought so _

A Note: The USB ports on my computer are powered as long as the power supply is on (even if the computer is not running). This provided the power needed for the Boarduino and allowed the circuit to function. I was able to run the USB cable out the back of the case and into a free USB port. Not the best way to power the circuit, I'll admit. I hope to have an updated version of this circuit that provides the same functionality in a more discrete manner. More on that later.

Step 2: The In-Line Transistor Circuit

A relatively simple circuit. Simple enough, even, to unceremoniously slap together and wrap up with a bit of electrical tape. I took off the tape for this picture. You've seen in the previous slide how it looked when finished. The inside of my computer is a rat's nest of wire already. Why not add some more? hehe.

I've said it was a simple circuit. But notice how I totally got the collector and emitter backwards. Yeah. Funny story about me a transistors. For part of my senior design project, we built a giant PVC pipe binary clock. It had 19 LED light clusters, each one needing to be toggled at the appropriate time by a micro-controller. We chose to use a similar transistor circuit that would turn on the light when the pin on the micro-controller was set high. Easy enough. Worked great in prototyping. Worked great all the time, actually. Even as a final product. But one day, our adviser comes in to have a look at the circuit. He asks me to take a look at the "orientation of the transistors."......*facepalm*. Every single one was backwards. But because the current draw of the lights was so low, the circuit functioned fine with the transistors reversed, which is why it never occurred to me during construction. As an electrical engineer, it was a very humbling experience. I told myself I would never make the same mistake again. mmmBahaha. We see how well that went...

(P.S. I hope to have another Instructable up eventually detailing the construction of that clock. Stay Tuned!)

Step 3: The (Bo)arduino Program

So short, It'll fit here. Based on one of the sample programs in the arduino library. Note that the '< 20' bit can be changed to make the circuit more or less sensitive. Having taken the thing apart for this Instructable, I can't, for the life of me, remember which direction results in higher sensitivity (i.e. whether a higher or lower number makes it more sensitive). My apologies. When I throw the circuit back together, I'll update accordingly.

//Sonic Switch Code
int analogPin = 0; //pin a0 on the board
int ledPin = 10; //pin 10 on the board
int analogValue = 0; //value from the ADC

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
// read analog input, divide by 4 to make the range 0-255:
analogValue = analogRead(analogPin);
analogValue = analogValue / 4;
if (analogValue < 20){
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
delay(10);
}

Step 4: (not So) Final Thoughts

Looking at it, it seems like a bit of overkill to use the ATMega168-powered Boarduino for such a simple circuit. I had toyed with the idea of trying a purely analog (no micro-controller) circuit to give the same functionality. I suppose it could be done, given the right component values and configuration. But I wanted to have the "Only On or Off" capabilities that a transistor triggered by a digital output pin offered. And I had a micro-controller lying around not doing anything and knew it would be easy to use it to get the desired effect. But I'd definitely be interested to see if anyone has any thoughts on a way to do this using just discrete components. Analog circuit design wasn't my strongest area of study (go figure, huh? hehe).

But I loves me some AVR chips (apparently). I recently purchased a USBtinyISP programmer from Adafruit Industries (http://www.ladyada.net/make/usbtinyisp/) and a couple of ATTiny25 chips from DigiKey. I've got a few projects lined up that might benefit from the tiny yet powerful ATTiny. I'd love to retool the Sonic Switch to use this chip. It certainly would take up less space and not add as much to the clutter already present in my computer. I'll be sure to detail the project in full once it gets underway.

If you've made it this far, thanks for reading through my first Instructable! I welcome any comments, questions, and constructive criticisms.