Need help changing a existing sketch to use 4 wire serial LCD

I have obtained a awesome sketch that runs a 2 lane slot car timer. The problem is I have a Tinkerkit LCD that enables a 4 wire serial port hook up as the illustrations I have attached shows.

I am also using two NTE3037NPN-Si Phototransistors, and there matching counter parts NTE3029b IR diodes, as the switches that sense when the cars pass through the light gantry. The Phototransistor has a Collector, emitter, and a base electrode. I am not sure what the base prong is for and I am uncertain if the coding will sense the signal the way it is written.

I am in way to deep for the knowledge I have with coding and IR sensors so I am reaching out for help from the exsperts. I will be very thankful for anyones help or suggestions…

Code I have is as follows

[quote]
#include <[color=#CC6600]LiquidCrystal[/color].h>
[color=#7E7E7E]/*[/color]
[color=#7E7E7E]VERSION 0.3 [/color]
[color=#7E7E7E]-Added Green LED For Best Round[/color]
[color=#7E7E7E]*/[/color
[color=#7E7E7E]// PIN CONFIGURATION[/color]
[color=#CC6600]LiquidCrystal[/color] lcd(12, 11, 5, 4, 3, 2);
[color=#CC6600]int[/color] laserPin = 13;
[color=#CC6600]int[/color] buttonPin1 = 7;
[color=#CC6600]int[/color] buttonPin2 = 8;
[color=#CC6600]int[/color] speakerPin = 9;
[color=#CC6600]int[/color] ledPin1 = 0; [color=#7E7E7E]// red [/color]
[color=#CC6600]int[/color] ledPin2 = 1; [color=#7E7E7E]// red[/color]
[color=#CC6600]int[/color] ledPin3 = 10; [color=#7E7E7E]// green[/color]
[color=#7E7E7E]/*[/color]

[color=#7E7E7E] States // The central state the timer is in[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E] 0 = pause;[/color]
[color=#7E7E7E] 1 = countdown;[/color]
[color=#7E7E7E] 2 = running;[/color]
[color=#7E7E7E] [/color]
[color=#7E7E7E]*/[/color]
[color=#CC6600]int[/color] state = 0;
[color=#CC6600]boolean[/color] displayLastRound = [color=#CC6600]true[/color];
[color=#CC6600]boolean[/color] running = [color=#CC6600]false[/color];
[color=#CC6600]int[/color] lightLevel = 0;
[color=#CC6600]long[/color] lastHit = 0; [color=#7E7E7E]//time of the last hit in the barrier (absolut)[/color]
[color=#CC6600]boolean[/color] lock; [color=#7E7E7E]// locks the light barrier while a car is passing. The look is removed as soon the car left the lightbeam and the roundTreshold time has passed[/color]
[color=#CC6600]long[/color] lastRound = 0; [color=#7E7E7E]// time of the lastround (absolut)[/color]
[color=#CC6600]long[/color] bestRound = 0; [color=#7E7E7E]// time of the bestround (relative)[/color]
[color=#CC6600]int[/color] roundNr = 0;
[color=#CC6600]int[/color] laserTreshold = 10;
[color=#CC6600]int[/color] roundTreshold = 300; [color=#7E7E7E]// minimum time that has to pass before a new round is counted[/color]
[color=#7E7E7E]// Absolut time for pressing buttons[/color]
[color=#CC6600]long[/color] lastPress1 = 0;
[color=#CC6600]long[/color] lastPress2 = 0;
[color=#7E7E7E]// LED Timer[/color]
[color=#CC6600]long[/color] timeLEDGreen = 0;
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
  [color=#CC6600]pinMode[/color](laserPin, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](buttonPin1, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](buttonPin2, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](speakerPin, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](ledPin1, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](ledPin2, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](ledPin3, [color=#006699]OUTPUT[/color]);
  [color=#7E7E7E]// set up the LCD's number of columns and rows: [/color]
  lcd.[color=#CC6600]begin[/color](16, 2);


  lcd.[color=#CC6600]setCursor[/color](0, 0);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Arduino"[/color]);
  lcd.[color=#CC6600]setCursor[/color](0, 1);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Laser Lap Timer  "[/color]);
  
  [color=#CC6600]delay[/color](1500);
  
  lcd.[color=#CC6600]setCursor[/color](0, 0);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Christoph &"[/color]);
  lcd.[color=#CC6600]setCursor[/color](0, 1);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Peter Halang    "[/color]);


  [color=#7E7E7E]//Serial.begin(9600);[/color]
  [color=#CC6600]delay[/color](1500);

}

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {

  [color=#CC6600]if[/color](![color=#CC6600]digitalRead[/color](buttonPin1)){

    button1Pressed();

  };

  [color=#CC6600]if[/color](![color=#CC6600]digitalRead[/color](buttonPin2)){

    button2Pressed();

  };



  [color=#CC6600]switch[/color] (state){
  [color=#CC6600]case[/color] 0: 
    statePaused(); 
    [color=#CC6600]break[/color];
  [color=#CC6600]case[/color] 1: 
    stateCountdown(); 
    [color=#CC6600]break[/color];
  [color=#CC6600]case[/color] 2: 
    stateRunning(); 
    [color=#CC6600]break[/color];
  }
}

[color=#CC6600]void[/color] didFinishRound(){
  [color=#CC6600]if[/color](roundNr > 0)lastRound = [color=#CC6600]millis[/color]()-lastHit;
  

  [color=#CC6600]if[/color] (bestRound == 0){
    bestRound = lastRound;
  }
  [color=#CC6600]if[/color] (lastRound < bestRound){
    bestRound = lastRound;
    timeLEDGreen = [color=#CC6600]millis[/color]()+1000;
  }
  lastHit = [color=#CC6600]millis[/color]();
  lock = [color=#CC6600]true[/color];  
  ++roundNr;
  displayLastRound = [color=#CC6600]true[/color];  

}

[color=#CC6600]void[/color] statePaused(){
  [color=#CC6600]digitalWrite[/color](ledPin1, [color=#006699]LOW[/color]);
  [color=#CC6600]digitalWrite[/color](ledPin2, [color=#006699]LOW[/color]);
  [color=#CC6600]digitalWrite[/color](ledPin3, [color=#006699]LOW[/color]);
  [color=#CC6600]digitalWrite[/color](laserPin,[color=#006699]LOW[/color]);
  lcd.[color=#CC6600]setCursor[/color](0, 0);
  lcd.[color=#CC6600]print[/color]([color=#006699]"Press right   "[/color]);
  lcd.[color=#CC6600]setCursor[/color](0, 1);
  lcd.[color=#CC6600]print[/color]([color=#006699]"button to start"[/color]);

}

serial-layout1.png

This seems more like a hardware issue than programming, perhaps should be moved to sensor section ?

Here is the code revised, Sorry

/*

VERSION 0.3 

-Added Green LED For Best Round

*/


// PIN CONFIGURATION
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int laserPin = 13;
int buttonPin1 = 7;
int buttonPin2 = 8;
int speakerPin = 9;
int ledPin1 = 0; // red 
int ledPin2 = 1; // red
int ledPin3 = 10; // green


/*

 States // The central state the timer is in
 
 0 = pause;
 1 = countdown;
 2 = running;
 
*/


int state = 0;
boolean displayLastRound = true;
boolean running = false;

int lightLevel = 0;
long lastHit = 0; //time of the last hit in the barrier (absolut)
boolean lock; // locks the light barrier while a car is passing. The look is removed as soon the car left the lightbeam and the roundTreshold time has passed

long lastRound = 0; // time of the lastround (absolut)
long bestRound = 0; // time of the bestround (relative)
int roundNr = 0;


int laserTreshold = 10;
int roundTreshold = 300; // minimum time that has to pass before a new round is counted

// Absolut time for pressing buttons
long lastPress1 = 0;
long lastPress2 = 0;


// LED Timer

long timeLEDGreen = 0;

void setup() {
  pinMode(laserPin, OUTPUT);
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(speakerPin, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);


  lcd.setCursor(0, 0);
  lcd.print("Arduino");
  lcd.setCursor(0, 1);
  lcd.print("Laser Lap Timer  ");
  
  delay(1500);
  
  lcd.setCursor(0, 0);
  lcd.print("Christoph &");
  lcd.setCursor(0, 1);
  lcd.print("Peter Halang    ");


  //Serial.begin(9600);
  delay(1500);

}

void loop() {

  if(!digitalRead(buttonPin1)){

    button1Pressed();

  };

  if(!digitalRead(buttonPin2)){

    button2Pressed();

  };



  switch (state){
  case 0: 
    statePaused(); 
    break;
  case 1: 
    stateCountdown(); 
    break;
  case 2: 
    stateRunning(); 
    break;
  }
}

void didFinishRound(){
  if(roundNr > 0)lastRound = millis()-lastHit;
  

  if (bestRound == 0){
    bestRound = lastRound;
  }
  if (lastRound < bestRound){
    bestRound = lastRound;
    timeLEDGreen = millis()+1000;
  }
  lastHit = millis();
  lock = true;  
  ++roundNr;
  displayLastRound = true;  

}

void statePaused(){
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);
  digitalWrite(ledPin3, LOW);
  digitalWrite(laserPin,LOW);
  lcd.setCursor(0, 0);
  lcd.print("Press right   ");
  lcd.setCursor(0, 1);
  lcd.print("button to start");

}

void stateRunning(){

  //switch laser on

  digitalWrite(laserPin,HIGH);


  //mesasure light

  lightLevel = analogRead(0);
  lightLevel = map(lightLevel, 0, 900, 0, 255);
  lightLevel = constrain(lightLevel, 0, 255);

  //Serial.println(lightLevel);
  // react to light

  if(lightLevel < laserTreshold){
    //digitalWrite(ledPin,LOW);
    lock = false;
  }
  else{
    // digitalWrite(ledPin,HIGH);
    if (millis()-lastHit > roundTreshold && lock == false){
      didFinishRound();
    }
  }

  // We have'nt finished the first round
  if(roundNr == 0){

    lcd.setCursor(0,0);
    lcd.print("Standby...      ");
    lcd.setCursor(0,1);
    lcd.print("                ");    

  }
  // Display the time and best / last round
  else{
    displaySecondLine();
    displayFirstLine();

  }
  
  // turn off all LED
  
  digitalWrite(ledPin1, LOW);
  digitalWrite(ledPin2, LOW);

  if (timeLEDGreen > millis()){
      digitalWrite(ledPin3, HIGH);
  }
  
  else{
      digitalWrite(ledPin3, LOW);
  }
  
  



}

void stateCountdown(){

  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("Ready             ");
  digitalWrite(ledPin1, HIGH);

  playNote('c',300);

  delay(1000);

  lcd.setCursor(0, 0);
  lcd.print("Set             ");
  digitalWrite(ledPin2, HIGH);

  playNote('c',300);

  delay(1000);

  lcd.setCursor(0, 0);
  lcd.print("Go             ");
  digitalWrite(ledPin3, HIGH);
  digitalWrite(laserPin,HIGH);

  playNote('g',600);

  state = 2;

}



void displayFirstLine(){

  lcd.setCursor(0, 0);


  lcd.print("Rd");
  lcd.print(" ");
  lcd.print(roundNr);
  lcd.print(" ");
  lcd.print(millis()-lastHit);
  lcd.print("ms");

  lcd.print("                       ");



}

void displaySecondLine(){

  lcd.setCursor(0, 1);

  if(displayLastRound){



    lcd.print("Last ");
    lcd.print(lastRound);
    lcd.print("ms");
    lcd.print("                       ");


  }



  else{
    lcd.print("Best ");
    lcd.print(bestRound);
    lcd.print("ms");
    lcd.print("                       ");

  }



}

void button1Pressed(){
  if(millis()-lastPress1 > 800){
    lastPress1 = millis();
    displayLastRound = !displayLastRound;
  }

}

void button2Pressed(){
  if(millis()-lastPress2 > 800){
    lastPress2 = millis();
    if (state == 0){
      state = 1;
    }
    if (state == 2){
      digitalWrite(laserPin,LOW);
      roundNr = 0;
      bestRound = 0;
      lastRound = 0;
      state = 0;
    }    

  }
}

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}
void playNote(char note, int duration) {
  char names[] = { 
    'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'   };
  int tones[] = { 
    1915, 1700, 1519, 1432, 1275, 1136, 1014, 956   };

  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}