Step 1: Gather Materials
a Mac computer
AppleScript Proxy from Tinker It! get it here: http://tinker.it/now/2007/04/26/control-your-mac-from-arduino-the-easy-way/
Arduino. I used a Duemilanove
USB cable for Arduino
A photoresistor. Available from any electronics parts store. I got mine at RadioShack. Should cost about $3 for 5.
a 10k resistor. Color code: Brown Black Orange
LED if you don't have on on your Arduino. Though it's optional then, too.
Gather the above materials and install the AppleScript Proxy.
Step 2: Build the Circuit
Step 3: Write an AppleScript.
tell application "iTunes" to play (next track)
and assigned it to character "A".
Step 4: Program the Arduino
pinMode(13,OUTPUT); //I'm using the built in LED on pin 13 to light up whenever the shadow conidtion is met.
//This is optional. If you have an older Arduino, you may attach your own LED to pin 13.
int lightlevel=analogRead(0); //reads the light level from the photoresistor and assigns it to the variable called lightlevel
delay(1000); //wait one second.
if (analogRead(0)<lightlevel-20) //if the light level changes by more than 20, it activates the shadow condition.
digitalWrite(13,HIGH); //turn LED on
Serial.print("A");//send signal to Mac, which interprets the A as a applescript command.
digitalWrite(13,LOW); //turns LED off.
/***Note: you have to stop the AppleScript program before uploading to the Arduino.
Step 5: Test It Out
It should work now!
Now hack it and see what else you can do!