Arduino + TouchOSC + Processing


I recently had an Arduino UNO purchased for me as a gift and I've been toying with it for the past few weeks and have the basics down (or so i thought) and now it is time to hit the forums. I am currently trying to use touchOSC with an extra iPod I have to use as a controller going forward for my projects.

I first started with making a simple light with 3 LEDs (RGB). I then uploaded the Firmata example to my Arduino and then put the code together for processing that interfaces with touchOSC. When I run the Processing sketch it creates a nice black window and sure enough, I can control the color of the background.

Now, from what I understand I do not need to do anything with the FirmataStandard example that comes with the IDE besides upload it to the board and processing should be able to handle the rest... Is this right? I tried the example from the Firmata page and it controls my lights exactly as I would like when I change the 9/10/11 pins to PWM mode. Why isn't processing talking to the Arduino?

If this is the wrong place to post this, I should be on a processing forum, or missing anything.. please don't hesitate to correct me!

Thank you for any and all of your help!

Arduino Code:
StandardFirmata Sketch Uploaded.

Processing Code:

import cc.arduino.*;
import processing.serial.*;
import oscP5.*;
import netP5.*;

//Instantiate Objects
OscP5 oscP5;
Arduino arduino;

float redAmount = 0.0f;
float greenAmount = 0.0f;
float blueAmount = 0.0f;

void setup(){
  //Set window size and background starting color
  oscP5 = new OscP5(this,8000); // Set listening Port
  arduino = new Arduino(this, Arduino.list()[0], 57600); //Serial connection

void draw(){
  background(redAmount, greenAmount, blueAmount); 
  // write to arduino
  arduino.analogWrite(9, int (redAmount));
  arduino.analogWrite(10, int (greenAmount));
  arduino.analogWrite(11, int(blueAmount));

 // OSC Linkage
void oscEvent(OscMessage theOscMessage){
  String addr = theOscMessage.addrPattern(); 
  float val = theOscMessage.get(0).floatValue();
  if(addr.equals("/Slider/faderRed")) {redAmount = val;}
  if(addr.equals("/Slider/faderGreen")) {greenAmount = val;}
  if(addr.equals("/Slider/faderBlue")) {blueAmount = val;}
  arduino = new Arduino(this, Arduino.list()[0], 57600); //Serial connection

Is the Arduino really connected to the first instance in the list? Print the list to make sure.

Thanks Paul S!

It was definitely 5th in the list.

Would it make sense to write some logic in to detect this?

Would it make sense to write some logic in to detect this?

Does the list change? Does the Arduino move around? If so, then it could make sense. Doing so is no trivial, though. You’ve have to send a message, wait for a response (but not forever), and make sure you got the expected response. Of course, the Arduino would need to send the correct response.