Hello,
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
size(320,480);
background(0);
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;}
}