Code Example

/*
  by Brian Patton
  3/04/15
  Feel free to do whatever you want with this code example
 */
int L_PhotoValue; // Variable to hold Left Sharp data
int R_PhotoValue; // Variable to hold Right Sharp data
const int L_PhotoPin = A2; //Pin connecting the Voltage Divider Board
const int R_PhotoPin = A1; //Pin connecting the Voltage Divider Board


void setup() {

  Serial.begin(9600); 
}

void loop() {
      L_PhotoValue = analogRead(L_PhotoPin); //Read the value of the sharp sensor
      R_PhotoValue = analogRead(R_PhotoPin); //Read the value of the sharp sensor
    
    for(int i = 0; i < L_PhotoValue/10; i++) // Move over Photovalue/10 blank spaces
    {
     Serial.print(" ");  //blank spaces
    }
    Serial.println("L"); //place a L at the end of the blank spaces
    
    for(int i = 0; i < R_PhotoValue/10; i++) // Move over Photovalue/10 blank spaces
    {
     Serial.print(" ");  //Blank Spaces
    }
    Serial.println("R");// Place an R at the end of the line
    delay(5);
}