I'm trying to make a graph of the serial data my arduino is sending back to the computer via processing. I realize this is a question to be asked on the processing board, but frankly the processing message board seems a little dead. The arduino is singing happily over serial port "/dev/ttyACM1" in the arduino IDE environment. However nothing I try will get any sort of connection in processing. In fact the serial.list() command doesn't even return any serial connections at all. There are no compile errors. Here is a basic program that isn't working. It simply doesnt return anything!
import processing.serial.*;
Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph
void setup () {
// set the window size:
size(400, 300);
// List all the available serial ports
myPort = new Serial(this, "/dev/ttyACM1", 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);
// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}else{
// increment the horizontal position:
xPos++;
}
}
}
before people chew me out for explicitly putting "/dev/ttyACM1" in there, I have tried all the variations of serial.list()[0] etc... to no avail. Any help would be appreciated.