In this Instructable I'll show how to control your stuff with your phone and the arduino board. I've controlled everything from smoke machines too christmas light's with this program.


sorry the video is kinda odd because my camera is trying to adjusting for the light difference.

Step 1: The Parts

The parts

-NPN transistor

-Iphone/ Android(Using Iphone)

-The TouchOSC app (awesome app)

-Arduino 5v (any type)

-some wire

-Soldering iron

-Breadboard (optional but recommended)

- A Mac or PC

-Some sort of remote or low power button (anything that runs on AA,AAA batteries is usually fine)

-If you want to control a appliance look at the last step fore more info.

and thats it!

Step 2: Open Your Device (low Power)

Hopefully you can figure out this step by yourself. Remove a screw or two and open it. In the pictures Im opening an LED strobe lamp.

Step 3: Find the Button

Now on the the circuit board from you device find the button/switch you want to control with your smartphone. For me it was the On/Off switch on the strobe lamp. if your opening a remote control you likely find these pads shown in the 2nd picture

Step 4: Solder to the Contacts

Once you have found the contacts solder some wire to them, one for the positive and another for the ground. I strongly recommend using solid strand wire as its much easier to solder. For more help look at the photos.

Step 5: Connect the Transistor

Now you will need to connect your transistor to your Arduino and to your device. Look at the picture below for how to wire it up. I have annotated it if you need help. That little black thing is your device.   If you know the polarity of the wires you can connect the positive to the left terminal of the transmitter and the ground to the right terminal 

If you  want to control more buttons connect additional transistor's the same way but instead of using pin 12 use 8, 9 or 11

Step 6: Make a TouchOSC Layout

Skip this step if your on Android!

1.Download the TouchOSC editor from here

2. Watch the video  for a quick how to, on creating a layout.

3.Make your own layout
Right click to make a button and select pushbutton
     you can have up to 4 buttons
4. When your done click the sync button and follow the on screen instructions.

Step 7: TouchOSC

1.Download TouchOSC  to your iPhone/ Android
I imagine you will be able to find  the app by searching for it on your local app store, if not go to hexler.net to find more info.

2.Find your IP
on a PC: start >run >cmd 

Once your in command line type "ipconfig" (without quotes) and hit enter. your iP is next to the line "IPv4 address" it should be in this format"" the 0's is your personal number

on a mac: click the apple at the top left of the screen, Then click about this mac.
Then more info. Then network. your ip will be under the IPv4 heading, it should be in this format"" the 0's is your personal number

3. configure TouchOSC
On a iPhone:
I have attached pictures at the bottom for help. Just match your pages to mine except the ip/host address where you can replace the ?'s with your own IP address. the first picture is the main page make sure stay connected is on, Then click the box that says not configured and set it up according to the second photo just replace the ?'s with your address.

On Android:
I don't actually own an Android so I'm not sure how to configure it  but i imagine it is very similar to the iPhone. If you own an Android device it would be great if you could post some pics to put in the Instructable

If you need any help just leave a comment below and i will try to help as fast as i can

Step 8: Setup the Programs

1. If you don't have  it already download processing IDE from processing.org.

2. You will need to download the oscP5 library for processing
     Go here  and download the library. Extract the files and move the folder oscP5 to this directory {C:\Users\[your user name]\Documents\Processing\libraries\[put the folder here]}

3. Open the the code which can be downloaded below and open it in it's respective program.
      For some reason Instructables renames the programs files so rema,e them back to the                 orignal (ControlArduino.pde) 
       The Processing IDE works just like the Arduino IDE.    File->open
      control Arduino goes with the Arduino IDE or  vice versa
4. Select the COM port for the Arduino board in the Arduino IDE and remember the number.
Tools-> serial port-> COM?

5. Bring up the processing IDE and change "COM4" in the line " arduinoPort = new Serial(this, "COM4", 9600)" to the Arduino serial port you found in the previous step.

Step 9: Try It Out/Troubleshoot!!

Your almost done 

1. Upload the code to the Arduino

2. Run the processing code.

3. Open the TouchOSC app
    Just hit done in the right corner.

4. Hope it works! 

If it doesn't work, don't fret.
You very likely got the polarity wrong. To solve this flip the wires that connect the transistor to your device and try it again. 

If it still doesn't work leave a comment below and i will try to help

Thank you for reading my instructable! please Vote for this If you like it!

Step 10: Expansions

Your probably thinking "This is great but how can i control my coffee maker with my phone?" 

Well here's the solution, You will need a relay. It allows you to control 110v/220v voltages. 
I recommend getting a power switch tail available here .
If you feel to do something more DIY Sparkfun has a tutorial that can be found here
And if your dumb like me you can buy a relay board off eBay by searching "relay 5V board Arduino" and parse it into a extension cable and shock yourself while doing it.

These boards connect the same way as a transistor.
You need a wifi shield correct??
Visit my instruction for how to download paid apps for free!!!!!!!!!!!!!!!!!!!!!!thanks
Is there any other options you might know besides arduino? I seen these Smart appliances at a pretty compact size. The size resembles something much smaller then an Arduino uno.
Hi, I can&acute;t get the code i processing to work. When I try to run it, it says Found one too many ( charaters without a ) match it. <br> <br>The Arduino stands with a constant voltage out from the transistor is that right also? <br> <br>Hope you can help :-)
hi, nice article, can you readd pde filoes? Because i can only download tem files, and when I rename them to pde, aplication is incomplete:<br>import processing.serial.*;<br>import oscP5.*;<br>import netP5.*;<br>OscP5 oscP5;<br>int alphaValue;<br>Serial arduinoPort;<br><br><br>float v_push1 = 0.0f;<br>float v_push2 = 0.0f;<br>float v_push3 = 0.0f;<br>float v_push4 = 0.0f;<br><br>void setup() {<br> size(320,440);<br> frameRate(25);<br> arduinoPort = new Serial(this, &quot;COM1&quot;, 9600);//change to the serial port arduino is on<br> /* start oscP5, listening for incoming messages at port 8000 */<br> oscP5 = new OscP5(this,8000);<br> <br>}<br><br>void oscEvent(OscMessage theOscMessage) {<br><br> String addr = theOscMessage.addrPattern();<br> float val = theOscMessage.get(0).floatValue();<br> <br> if(addr.equals(&quot;/1/push1&quot;)) { v_push1 = val; }<br> else if(addr.equals(&quot;/1/push2&quot;)) { v_push2 = val; }<br> else if(addr.equals(&quot;/1/push3&quot;)) { v_push3 = val; }<br> else if(addr.equals(&quot;/1/push4&quot;)) { v_push4 = val; }<br>}<br><br>void draw() {<br> background(0);<br><br> // fader5 + push 1-4 outlines<br> fill(0);<br> stroke(0, 196, 168); <br><br> rect(17,21,287,55);<br> rect(17,369,60,50);<br> rect(92,369,60,50);<br> rect(168,369,60,50);<br> rect(244,369,60,50);<br><br> // fader5 + push 1-4 fills<br> fill(0, 196, 168);<br> if(v_push1 == 1.0f) rect(22,374,50,40);<br> if(v_push2 == 1.0f) rect(97,374,50,40);<br> if(v_push3 == 1.0f) rect(173,374,50,40);<br> if(v_push4 == 1.0f) rect(249,374,50,40); <br> <br> if(v_push1 == 1.0f) arduinoPort.write(&quot;U&quot;);<br> if(v_push1 == 0.0f) arduinoPort.write(&quot;u&quot;);<br> if(v_push2 == 1.0f) arduinoPort.write(&quot;D&quot;);<br> if(v_push2 == 0.0f) arduinoPort.write(&quot;d&quot;);<br> if(v_push3 == 1.0f) arduinoPort.write(&quot;L&quot;);<br> if(v_push3 == 0.0f) arduinoPort.write(&quot;l&quot;); <br> if(v_push4 == 1.0f) arduinoPort.write(&quot;R&quot;);<br> if(v_push4 == 0.0f) arduinoPort.write(&quot;r&quot;); <br> <br> <br> <br><br>as I see the rest is missing.
It should run if it does not. Try this <br><br>import processing.serial.*;<br>import oscP5.*;<br>import netP5.*;<br>OscP5 oscP5;<br>int alphaValue;<br>Serial arduinoPort;<br><br><br>float v_push1 = 0.0f;<br>float v_push2 = 0.0f;<br>float v_push3 = 0.0f;<br>float v_push4 = 0.0f;<br><br>void setup() {<br>size(320,440);<br>frameRate(25);<br>arduinoPort = new Serial(this, &quot;COM1&quot;, 9600);//change to the serial port arduino is on<br>/* start oscP5, listening for incoming messages at port 8000 */<br>oscP5 = new OscP5(this,8000);<br><br>}<br><br>void oscEvent(OscMessage theOscMessage) {<br><br>String addr = theOscMessage.addrPattern();<br>float val = theOscMessage.get(0).floatValue();<br><br>if(addr.equals(&quot;/1/push1&quot;)) { v_push1 = val; }<br>else if(addr.equals(&quot;/1/push2&quot;)) { v_push2 = val; }<br>else if(addr.equals(&quot;/1/push3&quot;)) { v_push3 = val; }<br>else if(addr.equals(&quot;/1/push4&quot;)) { v_push4 = val; }<br>}<br><br>void draw() {<br>background(0);<br><br>// fader5 + push 1-4 outlines<br>fill(0);<br>stroke(0, 196, 168); <br><br>rect(17,21,287,55);<br>rect(17,369,60,50);<br>rect(92,369,60,50);<br>rect(168,369,60,50);<br>rect(244,369,60,50);<br><br>// fader5 + push 1-4 fills<br>fill(0, 196, 168);<br>if(v_push1 == 1.0f) rect(22,374,50,40);<br>if(v_push2 == 1.0f) rect(97,374,50,40);<br>if(v_push3 == 1.0f) rect(173,374,50,40);<br>if(v_push4 == 1.0f) rect(249,374,50,40); <br><br>if(v_push1 == 1.0f) arduinoPort.write(&quot;U&quot;);<br>if(v_push1 == 0.0f) arduinoPort.write(&quot;u&quot;);<br>if(v_push2 == 1.0f) arduinoPort.write(&quot;D&quot;);<br>if(v_push2 == 0.0f) arduinoPort.write(&quot;d&quot;);<br>if(v_push3 == 1.0f) arduinoPort.write(&quot;L&quot;);<br>if(v_push3 == 0.0f) arduinoPort.write(&quot;l&quot;); <br>if(v_push4 == 1.0f) arduinoPort.write(&quot;R&quot;);<br>if(v_push4 == 0.0f) arduinoPort.write(&quot;r&quot;); <br>}<br>
is it possible to change it a little bit to only send once to the arduino after you let go of a button? like some to the lines of <br> <br>if(v_push1 == 1.0f) <br>then(v_push1 == 0.0f) arduinoPort.write(&quot;1&quot;); <br> <br>so it reads that you push then sends the 1 once after you let go
yup, I think this should work but I don't have the chance to test it right now. <br>int var <br>if (v_push1 == 1.0f) { <br>var = 1; <br>} <br>else if(v_push == 0.0f &amp; var==1){ <br>var = 0; <br>arduinoPort.write(&quot;D&quot;); <br>} <br> <br>
works great till i add the other 2 buttons here is the last part would like help if its not a problem :) <br>void draw() { <br>background(0); <br> <br>// fader5 + push 1-4 outlines <br>fill(0); <br>stroke(0, 196, 168); <br> <br>rect(17,21,287,55); <br>rect(17,369,60,50); <br>rect(92,369,60,50); <br>rect(168,369,60,50); <br>rect(244,369,60,50); <br> <br>// fader5 + push 1-4 fills <br>fill(0, 196, 168); <br>if(v_push1 == 1.0f) rect(22,374,50,40); <br>if(v_push2 == 1.0f) rect(97,374,50,40); <br>if(v_push3 == 1.0f) rect(173,374,50,40); <br> <br> <br>if (v_push1 == 1.0f) { <br>var = 1; <br>} <br> else if(v_push1 == 0.0f &amp; var==1){ <br> var = 0; <br> arduinoPort.write(&quot;1&quot;); <br>} <br>if (v_push2 == 1.0f) { <br>var = 1; <br>} <br> else if(v_push2 == 0.0f &amp; var==1){ <br> var = 0; <br> arduinoPort.write(&quot;2&quot;); <br>} <br>if (v_push3 == 1.0f) { <br>var = 1; <br>} <br> else if(v_push3 == 0.0f &amp; var==1){ <br> var = 0; <br> arduinoPort.write(&quot;3&quot;); <br>} <br> <br>}
you will need a new &quot;var&quot; variable for each button so like &quot;var1&quot;, &quot;var2&quot; and so on
thankyou so much it works now
if i run this code the errors come out like this: <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br>sketch_oct30a:-1: error: variable or field 'oscEvent' declared void <br>sketch_oct30a:-1: error: 'OscMessage' was not declared in this scope <br>sketch_oct30a:0: error: 'import' does not name a type <br>sketch_oct30a:1: error: 'import' does not name a type <br>sketch_oct30a:2: error: 'import' does not name a type <br>sketch_oct30a:3: error: 'OscP5' does not name a type <br>sketch_oct30a:5: error: 'Serial' does not name a type <br>sketch_oct30a.cpp: In function 'void setup()': <br>sketch_oct30a:14: error: 'size' was not declared in this scope <br>sketch_oct30a:15: error: 'frameRate' was not declared in this scope <br>sketch_oct30a:16: error: 'arduinoPort' was not declared in this scope <br>sketch_oct30a:16: error: expected type-specifier before 'Serial' <br>sketch_oct30a:16: error: expected `;' before 'Serial' <br>sketch_oct30a:18: error: 'oscP5' was not declared in this scope <br>sketch_oct30a:18: error: expected type-specifier before 'OscP5' <br>sketch_oct30a:18: error: expected `;' before 'OscP5' <br>sketch_oct30a.cpp: At global scope: <br>sketch_oct30a:22: error: variable or field 'oscEvent' declared void <br>sketch_oct30a:22: error: 'OscMessage' was not declared in this scope <br> <br> <br> <br>help please!
looks like a line follower in the back
What about on Mac please respond
it should be almost exactly the same but you will have to find your network settings. I don't own a mac any more so I can't confirm whether it will work or not
I am getting this error message: <br> <br>ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage <br> to a method in your program. please check your code for any <br>possible errors that might occur in the method where incoming <br> OscMessages are parsed e.g. check for casting errors, possible <br> nullpointers, array overflows ... . <br>method in charge : oscEvent java.lang.reflect.InvocationTargetException
Sorry for the late response. Make sure the network settings are correct. <br>Is this error occurring while compiling or running?
Dude this is great I am just starting arduino and am wondering about where the contacts are and that whole step just confused me could u write me up a simpler way thank you
Step five was the confusing one
my Arduino doesn't seem to be registering any response form the app? i don't know if it has anything to do the the outgoing port? yours is 900 but i don't know if that is correct for me? when i run the processing code it loads my browser with a panel that looks something like the app once i click done but it does have the yellow bars or anything that the actual app has.
I am a bit unsure how to find the information being asked on step 8, 4 and 5. I am using a mac if it matters :]
By the way, does anyone knows good samples ar tutorial using TouchOSC and Microsoft Visual c++?
hey, i get &quot;&quot;osp5&quot; does not exist.&quot; error on controlproccesing.pde
Did you inserted libraary as sead in: <br> <br>2. You will need to download the oscP5 library for processing <br> Go here and download the library. Extract the files and move the folder oscP5 to this directory {C:\Users\[your user name]\Documents\Processing\libraries\[put the folder here]} <br>? <br>And after inserting you need to turn off all processing windows and rerun it :) <br> <br>
Sometimes this happens, it's just a glitch in processing youll have too download the oscp5 libary manually from here :http://www.sojamo.de/libraries/oscP5/#installation and set it up like the following [sketchbook DIR]/libraries/oscP5/library/oscP5.jar <br>You don't need to remove the jar from the folder.
if you don't want a pc in the middle, check out the ardumote app (http://bit.ly/nGBvjD). VERY easy to use, cheaper, and doesn't require a PC... it sends messages directly to the ethernet shield over WiFi.<br><br><br>http://www.youtube.com/watch?v=lX-VxmEOtIM
Hey, <br>Great writeup! Does this require a PC connection to the phone? I mean, after everything is configured and done, do you still need the PC on to operate the arduino?<br><br>Thanks alot!<br>Shane
You can control your arduino without a pc in the middle with the Ardumote app: here is a link to it on the app store: http://bit.ly/nGBvjD<br><br>found this video of it on youtube: http://www.youtube.com/watch?v=lX-VxmEOtIM
It does need a connection to the pc as the computer changes the osc commands into serial command which the arduino reads
Is there a way this could be controlled using a arduino ethernet shield and not have to use a computer? Thanks.
This may help http://recotana.com/recotanablog/closet . i need to buy one of those ethernet sheilds some time
What is the range of the communication? Does it only work within the same wifi network? I was just thinking it would be cool to control something in my house from across town :)
sorry for the late answer. No you do not need to be on the same wifi network but it requires some setup before it will work. I'll try to summarize the process. <br><br>1.go to your router configuration and forward the ports 8000 and 9000<br>2. if you do not have a static ip already (you likely have a dynamic IP) go to http://www.dyndns.com/services/dns/dyndns/ and install it and copy down the ip it gives you<br>3.In touchOSC input the ip you found in the last step in the network configuration setting for hostname<br>4. run it normally
Thanks, it works great! Awesome instructable. Now I'm working on making an IR remote so I can control my TV from my iphone :)
This may sound noobish, but how does the phone send the command to the arduino? Do you have a wifi shield for it or something? sorry im tired XD
The phone send an Osc signal through you're wifi network and processing then picks up this signal and send serial data through the USB cable and into the arduino. The arduino then responds with the appropriate output.
cool, thanks.<br>ive been playing around with the program, how would i get it to just do a digital output? i don't have transistors on me.
never mind, got it. thanks for great instructable!
Thank you. Awesome tesla coil I've always wanted to make one
they are fun :)
It already is. You can light an led. All the transistor is an electrically controlled switch.
Sweeet! I totally want to try this when I get some time =D
The robot is a TI EvalBot right?
wow that was quick! I would give you a patch but I'm not a pro,so a virtual high five will have to do.

About This Instructable




Bio: I live in Toronto, Canada and I build almost anything computer related, Anything from robots to computer interaction devices. My favorite programming language is C ... More »
More by mman1506:(reference)super simple CNC Control a Arduino with your phone. The kitchen sink prank, other classic & easy pranks 
Add instructable to: