Instructables

DIY iPhone controlled electronics

Picture of DIY iPhone controlled electronics
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

Picture of 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)

Picture of 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

Picture of find the button
100_1864.JPG
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 5: Connect the transistor

Picture of 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
-dami-19 days ago
Visit my instruction for how to download paid apps for free!!!!!!!!!!!!!!!!!!!!!!thanks
jmpm46192 months ago
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.
mslyngborg9 months ago
Hi, I can´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.

The Arduino stands with a constant voltage out from the transistor is that right also?

Hope you can help :-)
Udklip.JPGUdklip.JPG
raimuucka2 years ago
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)  raimuucka2 years ago
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");
}
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

if(v_push1 == 1.0f)
then(v_push1 == 0.0f) arduinoPort.write("1");

so it reads that you push then sends the 1 once after you let go
mman1506 (author)  oldsmarracin10 months ago
yup, I think this should work but I don't have the chance to test it right now.
int var
if (v_push1 == 1.0f) {
var = 1;
}
else if(v_push == 0.0f & var==1){
var = 0;
arduinoPort.write("D");
}

works great till i add the other 2 buttons here is the last part would like help if its not a problem :)
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_push1 == 1.0f) {
var = 1;
}
else if(v_push1 == 0.0f & var==1){
var = 0;
arduinoPort.write("1");
}
if (v_push2 == 1.0f) {
var = 1;
}
else if(v_push2 == 0.0f & var==1){
var = 0;
arduinoPort.write("2");
}
if (v_push3 == 1.0f) {
var = 1;
}
else if(v_push3 == 0.0f & var==1){
var = 0;
arduinoPort.write("3");
}

}
mman1506 (author)  oldsmarracin10 months ago
you will need a new "var" variable for each button so like "var1", "var2" and so on
thankyou so much it works now
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!
oldsmarracin10 months ago
looks like a line follower in the back
mr.eli1 year ago
What about on Mac please respond
mman1506 (author)  mr.eli1 year ago
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
ACKid1 year ago
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)  ACKid1 year ago
Sorry for the late response. Make sure the network settings are correct.
Is this error occurring while compiling or running?
mr.eli1 year ago
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 mr.eli1 year ago
Step five was the confusing one
strydom1 year ago
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 :]
raimuucka1 year ago
By the way, does anyone knows good samples ar tutorial using TouchOSC and Microsoft Visual c++?
hey, i get ""osp5" does not exist." error on controlproccesing.pde
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 :)

mman1506 (author)  TheTeslaWarrior3 years ago
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.
xshi262 years ago
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
flyinfinn3 years ago
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
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)  flyinfinn3 years ago
It does need a connection to the pc as the computer changes the osc commands into serial command which the arduino reads
jamilm93 years ago
Is there a way this could be controlled using a arduino ethernet shield and not have to use a computer? Thanks.
mman1506 (author)  jamilm93 years ago
This may help http://recotana.com/recotanablog/closet . i need to buy one of those ethernet sheilds some time
carjo30003 years ago
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)  carjo30003 years ago
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
Thanks, it works great! Awesome instructable. Now I'm working on making an IR remote so I can control my TV from my iphone :)
marselsipod3 years ago
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)  marselsipod3 years ago
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.
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!
mman1506 (author)  TheTeslaWarrior3 years ago
Thank you. Awesome tesla coil I've always wanted to make one
they are fun :)
mman1506 (author)  TheTeslaWarrior3 years ago
It already is. You can light an led. All the transistor is an electrically controlled switch.
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!