I am trying to plot the pulse sketch using processing IDE through arduino serialEvent function
my project is this ( Easily Take a Pulse with a Infrared Pulse Sensor | Make: )
So I have 1.Arduino code and 2.Processing sketch
Arduino code
/*
this goes on your Arduino
for use with Processing example IRPulseSensor
*/
// holds temp vals
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(0));
}
I Run this code in Arduino then switched to Processing for visualise the pulse peaks
No pulse peaks is appearing in processing after RUN the code only blank space
THEN after few minitues I got " error disabling serialEvent() for COM3" in processing then
I got this solution ( https://processing.org/discourse/beta/num_1217385866.html )
but i dont know how to run this code in arduino
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// serialEvent();
}
void serialEvent(Serial XBee) {
try {
//read a byte from the port
int curByte = XBee.read(A0);
//if the byte value is 0x7E, new packet
if (curByte == 0x7E) { //start the byte
if (packet[2] > 0) { //previous packet has been fully acquired
//write better test for this?
parseData(packet); //load the whole packet into the buffer
}
byteCounter = 0;
}
//put the current byte into the packet at the current position
packet[byteCounter] = curByte;
//increment byteCounter
byteCounter++;
} catch (Exception e) {
println("Initialization exception");
// decide what to do here
Serial.println(curByte);
}
}
ERROR is :
Serial_event:3: error: variable or field 'serialEvent' declared void
Serial_event:3: error: expected ')' before 'XBee'
Serial_event:8: error: variable or field 'serialEvent' declared void
Serial_event:8: error: expected ')' before 'XBee'
variable or field 'serialEvent' declared void