Sharp GP2Y0A710K0F IR sensor behaving strangely


i have purchased new sharp gp2y0a710k0f ir sensor online. sanity check, wrote simple code check if sensor working correctly. code expected print output voltage sensor, based on distance
code: [select]

    int sensorpin = a5;     
    int val = 0;   

    void setup()
    {
    serial.begin(9600);
    }
 
    void loop()
    {
    val = analogread(sensorpin);
    serial.println(val);   
    delay(100);
    }

now output quite strange. output values start 0 , keep on increasing until reach 1023, , gradually decrease down 0 , keeps on happening, if kept in front of sensor.

is sensor faulty one? or supposed give out similar outputs. if has to, how convert these values meter or centimeters.

the product description on manufacturer's website said has 3 pin interface, has 5 pin one, wires being red, black, yellow, white, green if seen left side. guessed datasheet red , black power , yellow signal output , hence have connected these 3 wires. green , white wires unconnected. also, pin numbers aren't marked.

datasheet: https://1drv.ms/b/s!anwpsnx8qqvugs0ynoxsvmuq2ordbq

// should map sensor 0 t 1023 0 255
//here's code
int sens = 0;
int sensp = 0;
void setup() {
serial.begin(9600);
}
void loop() {
sens = analogread(a0);  //let sensor coonected there
sensp = map(sens, 0,1023, 0,255);
serial.println(sensp);


Arduino Forum > Using Arduino > Sensors > Sharp GP2Y0A710K0F IR sensor behaving strangely


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'