Hey guys, I really need some help here. I don't know much about programming but thought this project looked easy enough. I have run into a few issues though. Currently, a line in the processing code "serial = new Serial (this, Serial. list() [serialPort], 115200);" is highlighted with an error that says "Array Index Out Of Bounds Exception: 2". I don't have any idea what this means and was hoping someone could help me. Here's the portion of the code I was talking about, the blue portion is the highlighted part:
import processing.serial.*;
import processing.opengl.*;
Serial serial;
int serialPort = 2; // << Set this to be the serial port of your Arduino - ie if you have 3 ports : COM1, COM2, COM3
// and your Arduino is on COM2 you should set this to '1' - since the array is 0 based
int sen = 3; // sensors
int div = 3; // board sub divisions
Normalize n[] = new Normalize[sen];
MomentumAverage cama[] = new MomentumAverage[sen];
MomentumAverage axyz[] = new MomentumAverage[sen];
float[] nxyz = new float[sen];
int[] ixyz = new int[sen];
float w = 256; // board size
boolean[] flip = {
false, true, false};
int player = 0;
boolean moves[][][][];
PFont font;
void setup() {
size(800, 600, P3D);
frameRate(25);
font = loadFont("TrebuchetMS-Italic-20.vlw");
textFont(font);
textMode(SCREEN);
println(Serial.list());
serial = new Serial(this, Serial.list()[serialPort], 115200);
for(int i = 0; i < sen; i++) {
n[i] = new Normalize();
cama[i] = new MomentumAverage(.01);
axyz[i] = new MomentumAverage(.15);
}
reset();
}
If you want to take a look at the project or the whole code, they can be found here: