I'm having a problem sending OSC messages to Max using the OSCP5 library. Here's my program. Basically, I'm getting values from the arduino and I want to print those values to Max but when I print the "analogInputMessage", I get something like this - "null:0 | /analog/0 i, null:0 | /analog/1 i, null:0 | /analog/2 i" as the value. I know that I'm getting values from the arduino perfectly fine. I can't figure out what is wrong. Why are the values null? Why isn't it adding them? Also, the oscEvent function isn't tripped when I run the program. It looks like it isn't sending anything. If you could help that would be much appreciated.
import processing.serial.*; // import the Processing serial library
import cc.arduino.*;
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Serial myPort;
Arduino arduino;
int incomingPort = 12000;
int outgoingPort = 12001;
String ipAddress = "127.0.0.1";
int [] analogInputData = new int [3];
int r = 0;
int g = 0;
int b = 0;
int [] data = new int [3];
int [] channelData = new int [3];
float ellipseRed, ellipseGreen, ellipseBlue;
void setup() {
size(1000, 1000);
oscP5 = new OscP5(this, incomingPort);
myRemoteLocation = new NetAddress(ipAddress, outgoingPort);
arduino = new Arduino(this, Arduino.list()[0], 57000);
for (int i = 0; i < 3; i++) {
analogInputData[i] = 0;
data[i] = 0;
channelData[i] = 0;
}
}
void draw() {
loadPixels();
for (int i = 0; i < 1000*1000; i+=10) {
for (int j = 0; j < 3; j++) {
analogInputData[j] = arduino.analogRead(j);
if (j == 0) {
r = int(map(analogInputData[j], 62, 675, 0, 255));
}
else if (j == 1) {
g = int(map(analogInputData[j], 62, 675, 0, 255));
}
else if (j == 2) {
b = int(map(analogInputData[j], 62, 675, 0, 255));
}
OscMessage analogInputMessage = new OscMessage("/analog/"+j);