English Vietnamese
Hotline : 0901.122.122
Product details
Name: SHARP 2Y0A21 10-80cm Infrared distance sensor (GP2Y0A21YK0F) (Update: 24/03/2015)
Weight
10 (gam)
Volume
20 (cm3)
Price
Number of Price
1 10 USD
5 9.57 USD
Residual
10+
Views
1,839
Document
Product information:
Hidden content 
 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

10-to-80cm-1.JPG
10-to-80cm-2.JPG
10-to-80cm-(1).JPG

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);

}