In the case of no object, the light is never reflected and the reading shows no object. This light travels out in the field of view and either hits an object or just keeps on going. The basic idea is this: a pulse of IR light is emitted by the emitter. This new rangers use triangulation and a small linear CCD array to compute the distance and/or presence of objects in the field of view. ![]() Voltage = (float)sensor_value*ADC_REF/1024 Sensor_value = analogRead(IR_PROXIMITY_SENSOR) *Return: -float,the voltage of the analog pin */įor (int i = 0 i < 20 i ++)//Continuous sampling 20 times *Function: Get voltage from the sensor pin that is connected with analog pin*/ wait 500 milliseconds before the next loop initialise serial communications at 9600 bps: on page 4 or page 5 of the datasheet of the GP2Y0A21YK. to the reflective object according to the figures board switches to 3V3, the ADC_REF should be 3.3įloat voltage //the sensor voltage, you can calculate or find the distance ![]() ![]() #define ADC_REF 5//reference voltage of ADC is 5v.If the Vcc switch on the Seeeduino #define IR_PROXIMITY_SENSOR A1 // Analog input pin that is attached to the sensor
0 Comments
Leave a Reply. |