hi, im new to arduino and i'm tryng to test some simple example of the learnig section of the site.
Now i'm stuck on "drimmer" example
(/arduino.cc/en/Tutorial/Dimmer)
i try to paste the code on processing tool and run it but don't work proprely. I'm pretty sure that the issue is on the serial com but i don't know how resolve it.
this is the code:
import processing.serial.*;
Serial port;
void setup() {
size(256, 150);
println("Available serial ports:");
println(Serial.list());
// Uses the first port in this list (number 0). Change this to
// select the port corresponding to your Arduino board. The last
// parameter (e.g. 9600) is the speed of the communication. It
// has to correspond to the value passed to Serial.begin() in your
// Arduino sketch.
port = new Serial(this, Serial.list()[0], 9600);
// If you know the name of the port used by the Arduino board, you
// can specify it directly like this.
//port = new Serial(this, "COM1", 9600);
}
void draw() {
// draw a gradient from black to white
for (int i = 0; i < 256; i++) {
stroke(i);
line(i, 0, i, 150);
}
port.write(mouseX);
}
this is the answer:
Available serial ports:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
processing.app.debug.RunnerException: ArrayIndexOutOfBoundsException: 0
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:582)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 0
at sketch_jan14a.setup(sketch_jan14a.java:36)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:636)
i also try to change whit:
port = new Serial(this, /dev/ttyACM0, 9600);
that is the com on my linux os.
thanks and best regards
