How to use sharp IR sensor with arduino
Components you'll need:
- Arduino uno
- Sharp GP2D12 or any other analog model like GP2D120
- Half sized breadboard
This is actually explained here but for ease of users i am posting it separately.
Connections:

You can power the arduino through USB or 9V battery.
Code:
int sensorpin = 0; // analog pin used to connect the sharp sensor int val = 0; // variable to store the values from sensor(initially zero) void setup() { Serial.begin(9600); // starts the serial monitor } void loop() { val = analogRead(sensorpin); // reads the value of the sharp sensor Serial.println(val); // prints the value of the sensor to the serial monitor delay(100); // wait for this much time before printing next value
}













conversion to inches or cm
Has anyone come up with a reliable conversion taking the voltages and converting to inches and/or cm?
Thanks,
Jim, K6JMG