Error at using SerialEvent void loop function

I am trying to plot the pulse sketch using processing IDE through arduino serialEvent function

my project is this ( http://makezine.com/projects/ir-pulse-sensor/ )

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

I don't see that there is much to go wrong with the first code that you posted but you might want to introduce a delay between each value sent. What baud rate is Processing using ?

The second code snippet that you posted has to do with receiving data not sending it. Why do you want to put that on the Arduino ?

UKHeliBob: I don't see that there is much to go wrong with the first code that you posted but you might want to introduce a delay between each value sent. "What baud rate is Processing using ?"

The second code snippet that you posted has to do with receiving data not sending it. Why do you want to put that on the Arduino ?

PRocessing Baurd rate is same as arduin 9600 baud rate If the first code is ok then why i could not able to see the pulses in processing sketch ? shows only blank

UKHeliBob: The second code snippet that you posted has to do with receiving data not sending it. Why do you want to put that on the Arduino ?

OH ! the second code is not for arduino , i thought it will send the data to serial port

As the Arduino code is so simple I would turn my attention to the Processing code. As an aid to debugging perhaps add a delay(100); after the Serial.println() in the Arduino code to temporarily slow down the frequency with which data is sent to Processing.

i will do it