DIY iPhone controlled electronics by mman1506
100_1887.JPG
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.




Video:

sorry the video is kinda odd because my camera is trying to adjusting for the light difference.
 
Remove these adsRemove these ads by Signing Up

Step 1: The parts

100_1861.JPG
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!
mman1506 (author) says: Feb 8, 2011. 6:05 PM
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
You don't need to remove the jar from the folder.
mr.eli says: Dec 27, 2012. 6:20 AM
What about on Mac please respond
mman1506 (author) says: Dec 27, 2012. 6:26 AM
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
ACKid says: Dec 7, 2012. 5:24 PM
I am getting this error message:

ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage
to a method in your program. please check your code for any
possible errors that might occur in the method where incoming
OscMessages are parsed e.g. check for casting errors, possible
nullpointers, array overflows ... .
method in charge : oscEvent java.lang.reflect.InvocationTargetException
mman1506 (author) says: Dec 27, 2012. 6:24 AM
Sorry for the late response. Make sure the network settings are correct.
Is this error occurring while compiling or running?
mr.eli says: Dec 27, 2012. 6:14 AM
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
mr.eli says: Dec 27, 2012. 6:15 AM
Step five was the confusing one
strydom says: Dec 1, 2012. 5:09 PM
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.
rklemka says: Apr 15, 2012. 3:41 PM
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:
import processing.serial.*;
import oscP5.*;
import netP5.*;
OscP5 oscP5;
int alphaValue;
Serial arduinoPort;


float v_push1 = 0.0f;
float v_push2 = 0.0f;
float v_push3 = 0.0f;
float v_push4 = 0.0f;

void setup() {
size(320,440);
frameRate(25);
arduinoPort = new Serial(this, "COM1", 9600);//change to the serial port arduino is on
/* start oscP5, listening for incoming messages at port 8000 */
oscP5 = new OscP5(this,8000);

}

void oscEvent(OscMessage theOscMessage) {

String addr = theOscMessage.addrPattern();
float val = theOscMessage.get(0).floatValue();

if(addr.equals("/1/push1")) { v_push1 = val; }
else if(addr.equals("/1/push2")) { v_push2 = val; }
else if(addr.equals("/1/push3")) { v_push3 = val; }
else if(addr.equals("/1/push4")) { v_push4 = val; }
}

void draw() {
background(0);

// fader5 + push 1-4 outlines
fill(0);
stroke(0, 196, 168);

rect(17,21,287,55);
rect(17,369,60,50);
rect(92,369,60,50);
rect(168,369,60,50);
rect(244,369,60,50);

// fader5 + push 1-4 fills
fill(0, 196, 168);
if(v_push1 == 1.0f) rect(22,374,50,40);
if(v_push2 == 1.0f) rect(97,374,50,40);
if(v_push3 == 1.0f) rect(173,374,50,40);
if(v_push4 == 1.0f) rect(249,374,50,40);

if(v_push1 == 1.0f) arduinoPort.write("U");
if(v_push1 == 0.0f) arduinoPort.write("u");
if(v_push2 == 1.0f) arduinoPort.write("D");
if(v_push2 == 0.0f) arduinoPort.write("d");
if(v_push3 == 1.0f) arduinoPort.write("L");
if(v_push3 == 0.0f) arduinoPort.write("l");
if(v_push4 == 1.0f) arduinoPort.write("R");
if(v_push4 == 0.0f) arduinoPort.write("r");




as I see the rest is missing.
mman1506 (author) says: Apr 15, 2012. 6:42 PM
It should run if it does not. Try this

import processing.serial.*;
import oscP5.*;
import netP5.*;
OscP5 oscP5;
int alphaValue;
Serial arduinoPort;


float v_push1 = 0.0f;
float v_push2 = 0.0f;
float v_push3 = 0.0f;
float v_push4 = 0.0f;

void setup() {
size(320,440);
frameRate(25);
arduinoPort = new Serial(this, "COM1", 9600);//change to the serial port arduino is on
/* start oscP5, listening for incoming messages at port 8000 */
oscP5 = new OscP5(this,8000);

}

void oscEvent(OscMessage theOscMessage) {

String addr = theOscMessage.addrPattern();
float val = theOscMessage.get(0).floatValue();

if(addr.equals("/1/push1")) { v_push1 = val; }
else if(addr.equals("/1/push2")) { v_push2 = val; }
else if(addr.equals("/1/push3")) { v_push3 = val; }
else if(addr.equals("/1/push4")) { v_push4 = val; }
}

void draw() {
background(0);

// fader5 + push 1-4 outlines
fill(0);
stroke(0, 196, 168);

rect(17,21,287,55);
rect(17,369,60,50);
rect(92,369,60,50);
rect(168,369,60,50);
rect(244,369,60,50);

// fader5 + push 1-4 fills
fill(0, 196, 168);
if(v_push1 == 1.0f) rect(22,374,50,40);
if(v_push2 == 1.0f) rect(97,374,50,40);
if(v_push3 == 1.0f) rect(173,374,50,40);
if(v_push4 == 1.0f) rect(249,374,50,40);

if(v_push1 == 1.0f) arduinoPort.write("U");
if(v_push1 == 0.0f) arduinoPort.write("u");
if(v_push2 == 1.0f) arduinoPort.write("D");
if(v_push2 == 0.0f) arduinoPort.write("d");
if(v_push3 == 1.0f) arduinoPort.write("L");
if(v_push3 == 0.0f) arduinoPort.write("l");
if(v_push4 == 1.0f) arduinoPort.write("R");
if(v_push4 == 0.0f) arduinoPort.write("r");
}
acalaguin says: Oct 29, 2012. 4:18 PM
if i run this code the errors come out like this:










sketch_oct30a:-1: error: variable or field 'oscEvent' declared void
sketch_oct30a:-1: error: 'OscMessage' was not declared in this scope
sketch_oct30a:0: error: 'import' does not name a type
sketch_oct30a:1: error: 'import' does not name a type
sketch_oct30a:2: error: 'import' does not name a type
sketch_oct30a:3: error: 'OscP5' does not name a type
sketch_oct30a:5: error: 'Serial' does not name a type
sketch_oct30a.cpp: In function 'void setup()':
sketch_oct30a:14: error: 'size' was not declared in this scope
sketch_oct30a:15: error: 'frameRate' was not declared in this scope
sketch_oct30a:16: error: 'arduinoPort' was not declared in this scope
sketch_oct30a:16: error: expected type-specifier before 'Serial'
sketch_oct30a:16: error: expected `;' before 'Serial'
sketch_oct30a:18: error: 'oscP5' was not declared in this scope
sketch_oct30a:18: error: expected type-specifier before 'OscP5'
sketch_oct30a:18: error: expected `;' before 'OscP5'
sketch_oct30a.cpp: At global scope:
sketch_oct30a:22: error: variable or field 'oscEvent' declared void
sketch_oct30a:22: error: 'OscMessage' was not declared in this scope



help please!
KevinAlien26 says: Jul 5, 2012. 1:43 PM
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 :]
rklemka says: Apr 24, 2012. 3:23 PM
By the way, does anyone knows good samples ar tutorial using TouchOSC and Microsoft Visual c++?
TheTeslaWarrior says: Feb 8, 2011. 5:46 PM
hey, i get ""osp5" does not exist." error on controlproccesing.pde
rklemka says: Apr 24, 2012. 3:20 PM
Did you inserted libraary as sead in:

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]}
?
And after inserting you need to turn off all processing windows and rerun it :)

xshi26 says: Jul 25, 2011. 11:37 PM
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.


http://www.youtube.com/watch?v=lX-VxmEOtIM
flyinfinn says: Apr 4, 2011. 10:27 AM
Hey,
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?

Thanks alot!
Shane
xshi26 says: Jul 25, 2011. 11:34 PM
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

found this video of it on youtube: http://www.youtube.com/watch?v=lX-VxmEOtIM
mman1506 (author) says: Apr 4, 2011. 5:19 PM
It does need a connection to the pc as the computer changes the osc commands into serial command which the arduino reads
jamilm9 says: Mar 30, 2011. 6:13 PM
Is there a way this could be controlled using a arduino ethernet shield and not have to use a computer? Thanks.
mman1506 (author) says: Mar 30, 2011. 6:18 PM
This may help http://recotana.com/recotanablog/closet . i need to buy one of those ethernet sheilds some time
carjo3000 says: Feb 15, 2011. 10:26 AM
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 :)
mman1506 (author) says: Feb 17, 2011. 5:06 AM
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.

1.go to your router configuration and forward the ports 8000 and 9000
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
3.In touchOSC input the ip you found in the last step in the network configuration setting for hostname
4. run it normally
carjo3000 says: Mar 1, 2011. 7:50 PM
Thanks, it works great! Awesome instructable. Now I'm working on making an IR remote so I can control my TV from my iphone :)
marselsipod says: Feb 8, 2011. 10:14 PM
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
mman1506 (author) says: Feb 9, 2011. 4:08 AM
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.
TheTeslaWarrior says: Feb 8, 2011. 6:27 PM
cool, thanks.
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.
TheTeslaWarrior says: Feb 8, 2011. 6:39 PM
never mind, got it. thanks for great instructable!
mman1506 (author) says: Feb 8, 2011. 6:47 PM
Thank you. Awesome tesla coil I've always wanted to make one
TheTeslaWarrior says: Feb 8, 2011. 7:24 PM
they are fun :)
mman1506 (author) says: Feb 8, 2011. 6:38 PM
It already is. You can light an led. All the transistor is an electrically controlled switch.
Jamo_G says: Feb 5, 2011. 8:36 PM
Sweeet! I totally want to try this when I get some time =D
computer_gui says: Feb 2, 2011. 10:17 PM
The robot is a TI EvalBot right?
mman1506 (author) says: Feb 3, 2011. 2:48 PM
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.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!