Description :
This popular IR based sensor from SHARP electronics is capable of producing analog signals in accordance with distance from the target object. The output value varies from 3.1V at 10cm to 0.3V at 80cm .Can be directly interfaced with SPDuino using the analog ports.
Features:
Distance measuring range: 10 to 80 cm
Analog output type
Specifications:
Supply voltage: 4.5 to 5.5 V
Consumption current: Typ. 30 mA
Test Code
void setup()
{
Serial.begin(9600);
}
void loop()
{
float X;
float V = analogRead(A0) * 5.0/1023.0;
if( V < 0.75 ) {
X = ( 27.0/(V - 0.08) ) - 1.8;
} else {
X = ( 34.0/(V + 0.08) );
}
Serial.println(X);
delay(500);
}