I'm trying to run this code with my arduino:
http://letsmakerobots.com/node/10577?page=1
Quote:import processing.serial.*;
Serial myPort; // The serial port:
int servo1 = 0;
int servo2 = 0;
int servo3 = 0;
int serialBegin = 255;
void setup() {
size(600,600);
myPort = new Serial(this, Serial.list()[1], 115200);
frameRate(100);
noCursor();
}
void draw() {
background(255);
triangle(width/2, height, 0, 200, width, 200);
servo1 = 100-int(dist(width/2,0,mouseX,mouseY)/6);
servo2 = 100-int(dist(0,height,mouseX,mouseY)/6);
servo3 = 100-int(dist(width,height,mouseX,mouseY)/6);
strokeWeight(3);
line(300,200,mouseX,mouseY);
line(150,400,mouseX,mouseY);
line(450,400,mouseX,mouseY);
println("X "+mouseX);
println("Y "+mouseY);
if (servo1 < 0){
servo1=0;
}
if (servo2 <0){
servo2=0;
}
if (servo3 <0){
servo3=0;
}
if (mousePressed && (mouseButton == LEFT)) {
servo1 -= 20;
servo2 -= 20;
servo3 -= 20;
}
if (mousePressed && (mouseButton == RIGHT)) {
servo1 += 40;
servo2 += 40;
servo3 += 40;
}
//println("servo1 "+servo1);
//println("servo2 "+servo2);
//println("servo3 "+servo3);
//Serial.write
myPort.write(255);
//delay(10);
myPort.write(servo1+30);
//delay(10);
myPort.write(254);
//delay(10);
myPort.write(servo2+30);
//delay(10);
myPort.write(253);
//delay(10);
myPort.write(servo3+30);
//delay(10);
}
and I get this error:
Code:
Error: ArrayIndexOutOfBoundsException: 1
Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 processing.app.debug.RunnerException: ArrayIndexOutOfBoundsException: 1 at processing.app.Sketch.placeException(Unknown Source) at processing.app.debug.Runner.findException(Unknown Source) at processing.app.debug.Runner.reportException(Unknown Source) at processing.app.debug.Runner.exception(Unknown Source) at processing.app.debug.EventThread.exceptionEvent(Unknown Source) at processing.app.debug.EventThread.handleEvent(Unknown Source) at processing.app.debug.EventThread.run(Unknown Source) Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 1 at sketch_apr10a.setup(sketch_apr10a.java:35) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:619)
at this line:
Quote: myPort = new Serial(this, Serial.list()[1], 115200);
Does anyone know what's going on? I'm totally in over my head here. I can barely get a "hello world" out the door.
More info: running windows 7 on my Acer Aspire D250. I have no mouse plugged in. Tried again with working wireless USB mouse plugged in and no change.