Arduino, OSC, iPhone and DMX

So what are we making?

The other day I started thinking about how I could design a better lighting desk for our basic lighting needs. The desk we currently have (Behringer EUROLIGHT) is poorly designed with more features than what we really need. I looked to OSC (Open Sound Control) as a protocol that could be used to control the lights via my arduino equipped with an ethernet shield.

NOTE: 25 Nov 2010. I’ve made a change to the Arduino sketch and to the OSC messages below. The DMX channel that is being controlled is now derived from the OSC message itself. ie. /dmx/3 would control DMX channel 3. Make sure to set your alpha channel in the arduino sketch.

Check the diagram below to see what we’ll be making.

Open Sound Control:

If you’ve never heard of Open Sound Control I recommend that you head over to the website to get a little background on it. Basically it’s an open standard that will allow us to send information over a standard network to our target device. You may be asking why use OSC for lighting? Don’t we just have to convert it back to DMX again to make it useful?

The reason OSC was chosen is that there is a bunch of OSC apps for the iPhone. Also it’s well documented with a lot being done in the developer community (check links at the end of this article).


DMX is the protocol that most lighting systems use today. It’s quite a old protocol but seems to work for most applications. I won’t go into depth here about the technical details of it. All you need to know is that we’ll be receiving our messages as OSC and using a simple function in our Arduino sketch to convert it to DMX. If you’d like to learn more about DMX check out this page.

Getting Started:

First a list of things we’ll need:

  • Arduino
  • Arduino OSC Library (see below)
  • DMXSimple Library
  • Ethernet Shield
  • LED par can
  • iPhone/iPod touch
  • Wireless Router
  • OSC conrtroller for iPhone (TouchOSC, iOSC, etc)
  • MAX485 or SN75176
  • 100 Ω resistor
  • Female XLR

The Ethernet Shield is not entirely mandatory as you could communicate through serial to processing but I won’t be covering that in this tutorial.  My method will give you a standalone device that will communicate to your lights without the need for a computer.

Arduino Code:

Here’s the code we need to load up on our Arduino. You’ll have to remember to change your network settings. On my particular network I use the address Also make sure to set the ‘alphaCh’ variable to reflect your lights alpha channel.

You’ll notice the OSC and the DMX libraries that are being loaded. Recotana has developed an OSC library for the arduino. I’ve modified the code slightly to allow the use of the OSC messages as variables without the trailing ‘/’. You can make the modification yourself by replacing lines 700-711 from the original OSCClass.cpp (v1.0.1) with the code below:

//Added this in to remove the slashes out of final output

    if(packetCount>3)  {


or you can download the one I’ve modified and put it in you arduino/libraries folder. The reason I modified the code is that it greatly simplified my arduino code and allowed me to extract the DMX channel from the OSC message and use it as a variable in my sketch.

You can download the DMX library here.

The Circuit:

Here’s a photo of the breadboard layout. I basically just used the schematic from the arduino website. I’ve just added an led and 220Ω resistor on the board to make sure the board is getting power. Those two components are not included on the below schematic. Also ignore the orange wire going to nowhere.

and the schematic:

The iPhone/iPod touch software:

I recommend iOSC because it’s quite configurable. The only downside is that the interfaces it comes with are limited and you cannot build your own like with TouchOSC. In either case you’ll have to setup your program to send out the appropriate OSC messages. Here’s a look at the settings we’ll use:

Label Message Value type min max
Slider 1 /dmx/1 float 0 1.00
Slider 2 /dmx/2 float 0 1.00
Slider 3 /dmx/3 float 0 1.00

Here’s a screenshot of the settings for the red slider:

Make sure your host settings reflect the network settings you set in your Arduino sketch. Here’s a look at my settings using iOSC:

Finishing Up:

Now all we have to do is plug everything in.

  • Hook up you light via XLR to your circuit.
  • Set your LED par can to the same DMX channel as your Arduino sketch settings.
  • Plug your arduino ethernet shield into your network. Make sure it’s on the same network as your iPhone/iPod Touch or it will not work.
  • Turn everything on and try it out. If it works you should be able to control the red, green, and blue channels of your light via your slider controls on your iPhone/iPod Touch.


In our next tutorial we’ll throw processing into the mix and show how you can use it to build a mixing interface and accept OSC messages then forward them on to your arduino.

  • I enjoyed reading this

  • Pingback: Arduino, OSC, iPhone and DMX-Lighting Control « Arduino projects collection()

  • Antonis Oulis

    hello!is this possible to happen without the Ethernet shield??
    by connecting the arduino with a usb cable to a laptop and the ipod and the laptop at a wifi network

    • Yes it is possible but you’ll have to modify the project slightly. I’ve accomplished this using Processing to talk to the arduino. I’ll be writing a tutorial about this in the future.

      • Daniel

        Hai Nick…i have running this and work perfectly with iPod,iPhone,iPad,but i cannot running with android????can u Help me,i already make the layout at touch osc editor,and make new touchosc.apk with my new layout,but still cannot light up the light???can u help met

  • Indiana

    Hi everybody,

    I have a project for school.
    I wish to light a led on an Arduino Board, thanks to a website coded in MXML (Flex).
    Here’s what I uhnderstand: both libraries ArdOSC and Dmx are used for the code in Arduino.
    But what about the website? What should I code in there to communicate with the OSC port of the Arduino? I don’t really understand, can someone help me?

  • Прикольная тема, продолжайте. Иногда нахожу ответы, которые получить самому просто реально не хватает времени. Большое спасибо!

  • Pingback: DMX and Arduino | Prodical's Blog()

  • Pingback: iPhone app review - TouchOSC | The Inner Qube()

  • Matthew watkins

    Great article rhanks

  • Ben


    I downloaded the example but it wouldn’t compile, it came up with this error:

    In file included from /Users/benjamin/Documents/Arduino/libraries/OSCClass/OSCClass.cpp:25:
    /Users/benjamin/Documents/Arduino/libraries/OSCClass/OSCClass.h:70:27: error: utility/types.h: No such file or directory

    I’ve downloaded the libraries and put them in the right place. Am I doing anything else wrong?

    Best wishes


  • Hey Ben,
    Not sure of a solution just yet. I think it’s due to the newest Arduino environment. When I made this project I believe I made it on arduino 0017 or 0018. Give one of those a try and it should at least allow you to upload the code. I’ll have to look into a better solution though.

  • Ben

    Hi Nick,

    That seemed to do the trick thanks, yes any version of Arduino after version 18 seems to not like the library. But I downloaded version 18 and is seemed to do the trick thanks.

    It’s ace by the way, works really well. No all I need to do it to try and get it to work with a Wifly shield 🙂


    • I worked a bit on recotana’s OSC library. I think I’ve got it working on 0021. I’ve zipped up the whole library so just copy over the old one (it also includes my modification to remove the ‘/’).

      Download OSC library

      Let me know if it works for you. If so I’ll include it in the tutorial.

  • zhao momma

    the new library works the old one crapps up my pc

    your 021 works with 022
    just need to import SPI library on sketches

  • Pingback: Stud-I/O » Archives du Blog » [Mur de la Cr34t1v1t3] Gestion du DMX()

  • Shing

    GREAT Article! it’s really impressive, thanku

  • RAY

    i can use osc touch and how i need change something

  • ray

    what is the code for arduino osc to dmx

    • Here’s the arduino code. This will receive the OSC message and output the DMX value. Don’t forget to set your IP and network settings though.

  • RAY

    in the config of mi osc touch to de buton 1 example is : ” /dmx/1″ that is for the chanel 1 /dmx/2 is for the chanel 2 etc no? i undestand that , is ok )

  • ray

    I understand that the configuration of the touch osc for example I have to put the button 1 / dmx / 1 to button 2 / dmx / 2 so until all channels configured as buttons and sliding

  • ray

    please help me

  • Hi ray, don’t forget to also use the modified osc library. It can be downloaded here:

    That will allow the arduino to pull the Dmx value right from the osc message.

    Also make sure your Dmx lights are set to the right channel. Most RGB Dmx lights will span 4 channels. A channel for red, green, blue, and brightness. So for example if a light is set to Dmx channel 10, 10 would be red, 11 green, 12 blue, and 13 the brightness.

    For you initial tests I recommend putting the brightness channel to full strength. In the above case we’d set channel 13 to 255.

    Hope that helps a bit.

  • RAY

    im lj and light tecnician the dmx i know but i d´ont know if the number of chanel i need config in the touch osc, but now i know thanks i whant make a interface for control moving heads whid the touch osc , i make one for control the midi in the tracktor scrach pro and is a copy in virtual of the traktor x1

    now i want make the same for moving heads i try ,

    ha my last cuestion the chip sn75176 you know some similar reference thanks

  • Erwin

    Hey Nick,

    Nice project. I would like to use is to control me RGB mood lichting in mij room.
    I purched the arduino board en Ethernet shield. But when i try to compile the code. I get a lot of error’s I included the ethernet. h en de OSCClass.h but the compiler still put a lot of comments on my screen.
    Thanx in advance.

  • Erwin

    Oh and sorry for my bad englisch i’m from holland.

  • Erwin

    Sorry it was my fault i put the libraries in the wrong folder

    • Glad you were able to sort it out

  • Erwin

    Now i have an other challenge :D,

    I tried your code with the new OSCClass lib, but it seems not to be working for me
    if i try to send a dmx command (in a new project) with only DmxSimple.write(3,255) or something like that my dmx lamp reacts like it should. then if i include the ethernet lib then the lamp doesn’t react toe any dmx command. in fact no dmx is send ?
    do you have any tips? if I upload your code with the right oscclass lib the ethernet port seems to recive some thing, sinds when I’am sliding a slider on my iphone de led’s on the ethhernet shield are blinking. Hope you can help me?

    Thanx in advance.

  • Erwin

    the include is not the problem, but as soon as i want to setup the netwerk, than it seems toe give a dmx signal my lamps tels me with a led on the back, en if I put a // in front of that line the lamp is reacting normal again.

  • VeryYes

    Hi there !

    What is the maximum number of lamps/DMX-receiving-devices that have been driven by this construction ?
    I’m planning on doing something similar for a band of a few friends of mine and this plan involves the usage of DMX-devices present on any location at which they are going to play.

    Now, I’ve read a couple of articles about Arduino and DMX and some point out, that the DMX-Output should be galvanically isolated from the rest of the board (by using so called optocouplers). This should prevent the board from being toasted by high electric potentials that could occur in DMX-setups. Have you ever had any problems or even a toasted arduino ?

    Thanks for any advice !

  • Theoretically I think the max is 512 devices. This is a limitation of the DMX protocol. I’ve never tested this project with more than 2 though so I’m not really sure to be honest.

    I’ve never had a problem with an Arduino being fried. If you are planning on building say a lamp that can be controlled by DMX you would want to make sure your mains voltage feeding your lamp is opto isolated from the actual DMX circuitry. Since we are plugging the arduino into commercial DMX products, they’ve done the isolation for us.

  • Hi dude,
    Can you please post the TouchOSC version? It is great idea that we have more choices of iPhone apps.


  • Pär

    Hey did someone get this to work with the Wifly Shield?

  • Ray

    Hi nick i start again whit my project becose one thief cach my mac whith mi proyect now y start again
    I have the dmx of sk pang whats is the pin i need use and my dmx tester dont recive the signal of dmx but de leds flashing when i touch the app on my ipad2
    Help , thanks again

  • Ray

    I use dmx ulate

  • Ray

    Hi again i use the dmx ulate app

  • austin

    Hi nick,
    i am currently on a project and trying to follow this example,
    i am using arduino uno R3, and also using the codes from the site u gave, the greatwhitenorth,
    one question tho, which code shld i load into the arduino?
    the TouchDmx, or the code u posted on sept 10 2011?

  • austin

    for now, no matter which sketch i run form ur greatwhitenorth, simple send and receive i get this error.

    “C:UsersKai XiangDesktopAVT FYParduino-1.0librariesEthernet/Ethernet.h:5:19: error: w5100.h: No such file or directory”

    i used to get this error,
    “C:UsersKai XiangDesktopAVT FYParduino-1.0librariesEthernet/utility/w5100.h:14:17: error: SPI.h: No such file or directory”
    but i managed to solve this by putting in #include “SPI.h”

    but i still cant find any available solutions on the net regarding the w5100 error. anyone encountered this error before and has solved it yet?

  • austin

    oh yeah btw, i am using touchosc instead of using iosc.

  • Fran

    Can you tell me how to start writing code in C++/Java that will receive osc messages please. I am on internship and my mentor is in Europe. i am supposed to come up with code in Java that receives osc messages from TouchOSC. I have no clue where to start. Also, I don’t have much experience in Java, just a few small programs from my sophomore year. I do have pretty good experience in C++. It’s very hard to communicate with my mentor (I’ve never even seen him) so I am looking for outside help. Please Help Me! Thanks in advance! I will be sure to mention all of your help.

  • ray

    hi nick i have a mac again and put this mesage help

    dmxulate.cpp:14:66: error: DmxSimple.h: No such file or directory
    dmxulate.cpp: In function ‘void setup()’:
    dmxulate:62: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp: In function ‘void loop()’:
    dmxulate:111: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp:14:66: error: DmxSimple.h: No such file or directory
    dmxulate.cpp: In function ‘void setup()’:
    dmxulate:62: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp: In function ‘void loop()’:
    dmxulate:111: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp:14:66: error: DmxSimple.h: No such file or directory
    dmxulate.cpp: In function ‘void setup()’:
    dmxulate:62: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp: In function ‘void loop()’:
    dmxulate:111: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp:14:66: error: DmxSimple.h: No such file or directory
    dmxulate.cpp: In function ‘void setup()’:
    dmxulate:62: error: ‘DmxSimple’ was not declared in this scope
    dmxulate.cpp: In function ‘void loop()’:
    dmxulate:111: error: ‘DmxSimple’ was not declared in this scope

    were i need put the dmx simple folder

  • how do I need to modify the arduino code for ArdOSC2.1?

  • Marc

    When I run the code, I get the following error…

    ArdOSC:28: error: variable or field ‘logMessage’ declared void
    ArdOSC:28: error: ‘OSCMessage’ was not declared in this scope
    ArdOSC:28: error: ‘mes’ was not declared in this scope
    ArdOSC:25: error: ‘OSCMessage’ does not name a type
    ArdOSC:27: error: ‘OSCClass’ does not name a type
    ArdOSC.ino: In function ‘void setup()’:
    ArdOSC:56: error: ‘osc’ was not declared in this scope
    ArdOSC.ino: In function ‘void loop()’:
    ArdOSC:66: error: ‘osc’ was not declared in this scope
    ArdOSC:72: error: ‘recMes’ was not declared in this scope
    ArdOSC.ino: At global scope:
    ArdOSC:95: error: variable or field ‘logMessage’ declared void
    ArdOSC:95: error: ‘OSCMessage’ was not declared in this scope
    ArdOSC:95: error: ‘mes’ was not declared in this scope

    I have downloaded all the libraries and have even tried running it on an older version of the Arduino software. I am stuck, and am on a deadline for work. Any ideas?

  • Pingback: WiFi Horizon, Best news updates, offers and business opportunities()

  • Daniel

    Hai Nick…i have running this and work perfectly with iPod,iPhone,iPad,but i cannot running with android????can u Help me,i already make the layout at touch osc editor,and make new touchosc.apk with my new layout,but still cannot light up the light???can u help me????

  • Pingback: RDM DMX resources. | Just Minutiae()

  • Nick

    Anywhere new to find that code? The link doesnt work anymore I dont think

  • Pingback: SuperCollider -> Arduino -> DMX | Tone and Manner()