Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
hayden.young1
hayden.young1's Profile
1
Posts
2
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Arduino and Osc thru processing
[4 Replies]
01-Mar-2011 06:03 PM
Forum:
Contributed Library Questions
i have written the folowing code and when i run it i get an error : arrayIndexOutOfBoundsExcepton: 0
import oscP5.*;
import netP5.*;
import processing.serial.*;
Serial arduinoPort;
OscP5 oscP5;
int motor1 = 0;
int motor2 = 0;
int [] m1 = new int [2];
int [] m2 = new int [2];
void setup()
{
size(200,100);
noStroke();
oscP5 = new OscP5(this,8000);
arduinoPort = new Serial(this, Serial.list()[0], 9600);
}
void oscEvent(OscMessage theOscMessage)
{
{
String addr = theOscMessage.addrPattern();
if(addr.indexOf("/1/toggle") !=-1){
int i = int((addr.charAt(9) )) - 0x30;
m1[i] = int(theOscMessage.get(0).floatValue());
}
}
{
String addr = theOscMessage.addrPattern();
if(addr.indexOf("/2/toggle") !=-1){
int i = int((addr.charAt(9) )) - 0x30;
m2[i] = int(theOscMessage.get(0).floatValue());
}
}
}
void draw() {
background(225);
if(m1[1] == 0){
arduinoPort.write("l");
motor1 = 0;
}
if(m1[1] == 1){
arduinoPort.write("L");
motor1 = 255;
}
fill(motor1,0,0);
ellipse(50, 50, 50, 50);
if(m2[1] == 0){
arduinoPort.write("l");
motor2 = 0;
}
if(m2[1] == 1){
arduinoPort.write("L");
motor1 = 255;
}
fill(motor2,0,0);
ellipse(50, 100, 50, 50);
}
«Prev
Next »
Moderate user : hayden.young1
Forum