Smartcar Shield
GP2Y0A02.ino

A basic example on how to get a distance measurement from a GP2Y0A02 infrared sensor.

#include <Smartcar.h>
const int SIDE_FRONT_PIN = A0;
ArduinoRuntime arduinoRuntime;
GP2Y0A02 sideFrontIR(arduinoRuntime,
SIDE_FRONT_PIN); // measure distances between 25 and 120 centimeters
void setup()
{
Serial.begin(9600); // start the serial
}
void loop()
{
Serial.println(sideFrontIR.getDistance());
delay(100);
}