Programming reflective optical sensor TCRT1000

Hi peeps, i would like to program the refelctive optical sensor TCRT1000 on my arduino board. i would like it to read the readings from my wrist and display a waveform onto labview. This is the program, please guide and correct me if i am wrong. thanks in advance (:

int an1, an2, an3 = 0;

void setup() { Serial.begin(19200); }

void loop() { an1 = analogRead(0); delay(5); // an2 = analogRead(1); delay(5); // an3 = analogRead(2); Serial.print(“X”); Serial.println(an1,DEC); // Serial.print(“Y”); // Serial.println(an2,DEC); //Serial.print(“Z”); //Serial.println(an3,DEC); delay(15); }

Processing:

import processing.serial.*;

String buff = “”; int val = 0; int xPos,yPos,zPos = 0; int displaySize = 10 ; int an1; int an1synth;//synthesized value so the waveform is a little clearer for now int threshold= 3;// have a constant threshold value //an1 pot; an2 ir; int lastx=0; int lasty=0; int marker;//counter for checking 60 second intervals boolean finterval=false;

Serial port;

void setup() { background(80); size(800,600); smooth(); port = new Serial(this, Serial.list()[1], 9600); }

void draw(){ // new background over old fill(80,5); noStroke(); rect(0,0,width,height);

// wipe out a small area in front of the new data stroke(255,0,0); line(0,375,800,375);//threshold line noStroke(); fill(80); rect(xPos+displaySize,0,50,height);

// check for serial, and process while (port.available() > 0) { serialEvent(port.read()); }

}

void serialEvent(int serial) { float m = millis(); float m1=(m%60000); println(“m1 is” + m1); if(m1 ==0)//check if 60 samples are done and draw a vertical black line { print(“set to true”); stroke(255);// white vertical line line(lastx,400, lastx, 0); // marker=0;//reset marker back to zero } print(” Value of Sensor X “); //header variable, so we know which sensor value is which println(an1); //send as a ascii encoded number – we'll turn it back into a number at the other end //Serial.print(10, BYTE); //terminating character if(serial != '\n') { buff += char(serial); //print(“debug this serial ["+serial+"]“); } else { int curX = buff.indexOf(“X”); //print(“debug this buffer ["+buff+"]“); if(curX >=0) { String val = buff.substring(curX+1); an1 = Integer.parseInt(val.trim()); an1synth=(an1*100)/10; xPos=xPos+2; if(xPos > width) { xPos = 0; } /sensorTic2(xPos, 400- threshold ); xPos++;/ sensorTic1(xPos,400- an1synth); } // Clear the value of “buff” buff = “”; } }

void sensorTic1(int x, int y) { //stroke(0,0,255); stroke(0,0,255); //fill(255,0,0); //ellipse(x,y,displaySize,displaySize); line(lastx, lasty, x,y); lastx=x; lasty=y; }