Hello,
I am using a Macbook pro, OSX10.5.5 with the latest version of java. I am hooking up my arduino board to my port with a simple photocell circuit; however, when I run my processing code to draw the sketch and illustrate my photocell's light data, it gives me this error message:
processing.app.debug.RunnerException: unexpected token: void
at processing.app.Sketch.preprocess(Sketch.java:1369)
at processing.app.Sketch.build(Sketch.java:1478)
at processing.app.Sketch.compile(Sketch.java:1178)
at processing.app.Editor.handleRun(Editor.java:1645)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:321)
at java.awt.Component.processMouseEvent(Component.java:5599)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3933)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
processing.app.debug.RunnerException: unexpected token: void
at processing.app.Sketch.preprocess(Sketch.java:1369)
at processing.app.Sketch.build(Sketch.java:1478)
at processing.app.Sketch.compile(Sketch.java:1178)
at processing.app.Editor.handleRun(Editor.java:1645)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:321)
at java.awt.Component.processMouseEvent(Component.java:5599)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3933)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
This is my processing code:
/*
* pa_Potentiometer
*
* Reads the values which represent the state of a potentiometer
* from the serial port and draws a graphical representation.
*
* This file is part of the Arduino meets Processing Project.
*
* copyleft 2005 by Melvin Ochsmann for MalmUniversity
*
*/
// importing the processing serial class
import processing.serial.*;
import processing.net.*;
Server myServer;
myServer = new Server(this, 8080);
int ZERO = 0;
// the display item draws background and grid
DisplayItems di;
// definition of window size and framerate
int xWidth = 980;
int yHeight = 512;
int fr = 24;
// attributes of the display
boolean bck = true;
boolean grid = true;
boolean g_vert = true;
boolean g_horiz = false;
boolean g_values = true;
boolean output = true;
// variables for serial connection, portname and baudrate have to be set
Serial port;
String portname = "/dev/tty.usbserial-A9003VR1";
int baudrate = 9600;
int value = 0;
String buf="";
int value1=0;
// variables to draw graphics
int xpos;
// lets user control DisplayItems properties and value output in console
void keyPressed(){
if (key == 'b' || key == 'B') bck=!bck; // background black/white
if (key == 'g' || key == 'G') grid=!grid; // grid ON/OFF
if (key == 'v' || key == 'V') g_values=!g_values; // grid values ON/IFF
if (key == 'o' || key == 'O') output=!output; //turns value output ON/OFF
}
void setup(){
// set size and framerate
size(xWidth, yHeight);
//frameRate(fr);
// establish serial port connection
println(port.list());
port = new Serial(this, portname, baudrate);
// create DisplayItems object
di = new DisplayItems();
}
void drawPotiState(){
noStroke();
fill(0, 0, 255);
// draw rectangfle at xpos
rect(xpos, 0, width/32+(xpos/200), height);
fill(255);
// and xpos as text
text(""+xpos , xpos, height/2);
}
void serialEvent(int serial){
// if serial event is not a line break
if(serial!=10) {
// add event to buffer
buf += char(serial);
} else {
// if serial is line break set value1 to buff and clear it
value1 = int(buf);
println(value1);
buf="";
}
// convert value1 to xpos
xpos = constrain ( ( ((value1-100)*(width+100))/width ) ,0, width-12);
if(output) println("xpos: "+xpos);
}
// draw listens to serial port, draw
void draw(){
// listen to serial port and trigger serial event
while(port.available() > 0){
value = port.read();
serialEvent(value);
}
// draw background, then PushButtonState and finally rest of DisplayItems
myServer.write(val);
myServer.write(ZERO);
di.drawBack();
drawPotiState();
di.drawItems();
}
Could there be a problem with java ? or the Server that is set up ?