Thursday, January 31, 2013

Trying the Sharp Sensor

The datasheet  of GP2Y0A02YK0F might be handy...

I first connected GND to ground, VCC to +5 V pins and V0 to Analog zero (A0)

And first tried an slightly adapted version of ReadAnalogVoltage

void setup() {
  Serial.begin(115200);
}
void loop() {
  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);
  Serial.println(voltage);
  delay(1000);
}
 The output is the voltage on AO


2.45
2.33
0.48
1.62
2.17
2.23
0.36
0.36
0.34
1.11
0.02
1.80
1.83
1.97
2.11
2.15
2.33
2.39
High values are close range and low values are long range just like the datasheet tells me.

Next step change measurements to the metric system. 
I found this blog post doing a linear mapping. But the datasheet() shows me its a nonlinear relationship between distance and voltage so I would like to find a arduino library.

Yay a little googleing later I found http://code.google.com/p/gp2y0a21yk-library/ but that is for the little brother of this sensor with lower range...

And then I found this resource for linearizing output ... 

to be continued....


Sharp Sensor Recieved

Sharp GP2Y0A02YK0F Infrared Distance Sensor
I Just recieved the Sharp GP2Y0A02YK0F Distance sensor from Lawicel Shop. The order was placed 2013-01-29  and I recieved the sensor today 2013-01-31. Fast service for the win!

Say hello to "Flip"!
Flip is Scanning
My plan is to place the sensor on "Flip". Flip is currently using a HC-SR04 ultrasound distance sensor and the current sensor is quite wide around 15 degrees beam, which makes it great for obstacle avoidance but kind of blurry for mapping.
Flip  ultrasound sensor scan ASCII image.