We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am using processing to plot the graph for two sensor's connect to arduino analog pin 0 and 1 and controlling LED at pin 13. I am using serial data format sensor1_value , sensor2 _value /n
my processing code and arduino code is attched. While running the code I am getting erroe meaage
Error, disabling serialEvent() for COM2 null
this code works for 1st time after that it keeping showing this error and also this code works fine for single sensor.
Kindly help me...I am new to processing
my processing code is:
import processing.serial.*;
Serial myPort;
int val1, val2, scr_inc1, scr_inc2, old_x1=0, old_y1=0, old_x2=0, old_y2=0;
String inString, str1, str2;
int lf=10;
void setup()
{
size(displayWidth-100, 600);
String portName=Serial.list()[0];
println(Serial.list());
myPort=new Serial(this, portName, 9600);
myPort.bufferUntil(lf);// use '/n'
background(0, 0, 0);
//smooth();
}
void draw()
{
}
void serialEvent(Serial myPort)
{
inString=myPort.readString();
inString=trim(inString);
int pos=inString.indexOf(',');
//sensor 1
str1=inString.substring(0, (pos-1));
val1=int(str1);
strokeWeight(1);//line width
stroke(62, 160, 6);
line(old_x1, old_y1, scr_inc1, 600-val1);
old_x1=scr_inc1;
old_y1=600-val1;
scr_inc1=scr_inc1+2;
//sensor2
int len=inString.length();
str2=inString.substring((pos+1), (len-1));
val2=int(str2);
strokeWeight(1);//line width
stroke(182, 11, 222);
line(old_x2, old_y2, scr_inc2, 600-val2);
old_x2=scr_inc2;
old_y2=600-val2;
scr_inc2=scr_inc2+2;
//send data to arduino
/* if(val1>500)
{
myPort.write('1');
}
if(val1<300)
{
myPort.write('0');
}*/
//restart screen
if (scr_inc1>(displayWidth-100))
{
background(0, 0, 0);
scr_inc1=-50;
scr_inc2=-50;
old_x1=-50;
old_y1=0;
old_x2=-50;
old_y2=0;
}
}
Answers
Please format the code it's difficult to read, leave one blank row from your text and press CTRL + K, or the C in the editing bar.
hi SilentAce ... This code works sometime and sometime its shows disabling serialEvent() error in console
plz help
Deleted redundant messages. See To newcomers in this forum: read attentively these instructions