Specification
- Measuring Detecting distance : 10 to 80 cm
- The maximum allowable Angle : > 40 °
- The power supply voltage : 4.5 to 5.5 V
- The average power consumption : 35 mA
- Peak power consumption : about 200 mA
- The frequency of updates/cycle : 25 Hz/40 ms
- Analog output noise : < 200 mV
- Less influence on the color of reflective objects, reflectivity
- Line-up of distance output/distance judgement type :
- Distance output type (analog voltage) : GP2Y0A21YK
- Distance judgement type : GP2Y0D21YK
- Judgement distance : 24cm
- (Adjustable within the range of 10 to 80cm [Optionally available])
Code
int i;
int val;
int redpin=0;
void setup()
{
pinMode(redpin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
i=analogRead(redpin);
val=(6762/(i-9))-4;
Serial.println(val)