Arduino OSC step by step howto


This tutorial provide step by step that help you to  setup a OSC ready Arduino which allows you to send instruction to your Arduino wirelessly from your iOS/Android device by using TouchOSC.

Suppose you have basic knowledge on computer networking, and Arduino, and we are going to cover the following topics.

1. Hardware Setup

  • Show you how they connected together.
  • The network setup

2. Software Setup

  • The exact Arduino coding
  • Composing TouchOSC interface
  • TouchOSC Setup on iOS

3. The Demo

  • Show you the result of the setup

1. Hardware Setup

Setup Diagram

Let’s take a look the setup diagram, see how this connected.

  • A servo connected to Digital Pin 13
  • Arduino ethernet assigned a IP
  • iOS will be assigned a IP by DHCP

Hardware Components


You need the following component to construct your setup

1. Arduino board (Mega 2560, UNO…etc)

2. Arduino compatible ethernet Shield

3. Low power consumption servo unit, recommend a mini or micro sized servo.

4. Power supply, for example 5v, 2A

5. Wireless AP/Router, DHCP enabled.

Let’s Hook them up

Let’s start to hook them shown as below

Hookup Image
Signal Pin
Servo Power Pin

2. Software Setup


Let’s move on core part, make sure Arduino IDE and Z_OSC is inplace.

Arduino IDE

Arduino IDE

Download and Install Arduino IDE –

Z-OSC Library

Download Z-OSC library –

Extract Z_OSC library folder into C:\Users\%USERNAME%\Documents\Arduino\libraries\

Code it

Modify IP Addresses

You may change the IP Address for the Arduino and your iOS/Android to fit your setup.

For example: on iOS

Then search “myIp” line

byte myIp[]  = { 192, 168, 0, 178 }; // Specify your arduino  IP here

and the “destIp” line.

byte myIp[]  = { 192, 168, 0, 12 }; // your IPad Address here<

// Receive from iOSC and apply to arduino pins via OSC .
// Credits to Jerome Dupraz & Retocama
// Colorsound 011
// you can download arduino z-osc library from here
// you can download arduino code and vvvv patch from here:


This is a sample code for controlling servo via TouchOSC



byte myMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte myIp[]  = { 192, 168, 0, 178 }; // Specify your arduino  IP here
int  serverPort  = 8000; // and listening port as well

byte destIp[] =  { 192, 168, 0, 12 }; // Your iPad/Android IP here
int  destPort = 9000;

float val;// delcare a variable for reading values

// create servo object to control a servo, remember to attach them in setup()
Servo myservo1;

Z_OSCClient client;
Z_OSCServer server;
Z_OSCMessage *rcvMes;
Z_OSCMessage message;

void setup(){
 myservo1.attach(13); // attaches the servo on pin 13 to the servo object
 Ethernet.begin(myMac ,myIp);

void loop(){

     // myservo1
     if( !strcmp( rcvMes->getZ_OSCAddress() ,  "/1/toggle1" ) )
      val = rcvMes->getFloat(0);
      if ( val > 0 ) {
          message.setZ_OSCMessage( "/1/toggle1_msg" ,"s" , "Moved" );
      } else {
          message.setZ_OSCMessage( "/1/toggle1_msg", "s" , "" );



Upload into Arduino board

Once you finish your modification, upload it to Arduino, make sure you set the correct board model and serial port nubmer.

Upload it.


Once the code upload succeed, then try to ping the Arduino IP address eg:

If your andrino didn’t respond the ping, or you do hear the servo is being noisy, shaking..etc, it is probably causing by power issue. Try to feed Arduino with extra power current either plus on-board power source or USB power.


Congratulations, this is the last fun part. You need TouchOSC application on iOS/Android, and the TouchOSC editor for customization and managing/upload your OSC layout.

Download TouchOSC Editor here  –

And the TouchOSC – From AppStore or Play Store

Edit TouchOSC Layout

Let start with this OSC layout sample

Download Arduino OSC Tutorial OSC Layout

Main Editor Window

This sample template, included two static text label, one toggle button for triggering the servo movement, and one blank label area that receive arduino text message.

OSC Objects

Toggle button

It cosist two important parameters used to communicate with arduino and servo.

1. OSC Name: /1/toggle1

/1/toggle1 is corresponding to getZ_OSCAddress line in Arduino code.

2. Value Range: 0 To 62

This value specify two exact degree angle of the servo while the toggle switch trigged,   please adjust it as you like.

Toggle Msg label

This label area is receiving text message where send back from Arduino, we leave the “text” field empty first. When the servo triggered, Arduino send back a word “Moved” in the label area.

OSC Name: /1/toggle1_msg

The OSC name is corresponding to “setZ_OSCMessage” in Arduino code.

Sync the OSC layout

Once you have done your modification, push it to the App.

Click “Sync” on the editor menu bar.

When you see this dialog, then please move on iOS TouchOSC app.

TouchOSC on iOS

Popup TouchOSC app on your iOS, enter into info page, select “Layout”->”Add” to retrieve the layout from your PC, if no PC host was discovered, then you may try to add the PC IP address. Ensure your firewall is not blocking incoming connection.

Click the current layout, and then “Add”
Select the Host which running TouchOSC editor
Select the newly added layout “Arduino OSC Tutorial”

Once you click on the PC IP Address, the new layout will push into your iOS.

Connection Setting

One more step to go, to setting up the arduino IP address in TouchOSC.

At the connection setting, click into the OSC:, and then specify the IP address which assigned to arduino.


Demo Video

Let’s have fun!


2 Replies to “Arduino OSC step by step howto”

Leave a Reply