i have written the following code in processing...
- import processing.serial.*;
- Serial myPort;
- int valX,valY;
- void setup()
- { background(0);
- size(1024,1024);
- myPort=new Serial(this,Serial.list()[0],9600);
- }
- void draw()
- { void serialEvent(Serial myPort) //unexpected token:void
- {
- String myString=myPort.readStringUntil(124);
- if(myString!=null)
- {
- myString=trim(myString);
- int inputs[]=int(split(myString,','));
- if(inputs.length==2)
- { valX=inputs[0];
- valY=inputs[1];
- }
- }
- }
- mouseX=valX;
- mouseY=valY;
- fill(225);
- ellipse(mouseX,mouseY,2,2);
- if(mousePressed)
- {background(0);
- }
- }
int potX=A0;
Its giving me an error while declaring the serialEvent as "unexpected token:void".
processing.app.SketchException: unexpected token: void
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:326)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
at java.lang.Thread.run(Thread.java:662) the arduino code is
processing.app.SketchException: unexpected token: void
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:326)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
at java.lang.Thread.run(Thread.java:662) the arduino code is
- int potY=A1;
- int valX,valY;
- void setup()
- { Serial.begin(9600);
- }
- void loop()
- {
- valX=analogRead(potX);
- valY=analogRead(potY);
- Serial.print(valX,DEC);
- Serial.print(",");
- Serial.print(valY,DEC);
- Serial.print("|");
- }
1