Pages: [1]   Go Down
Author Topic: Sharp gp2d120  (Read 875 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I have been testing my Sharp gp2d120 sensor with this code

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println(analogRead(0));
  delay(100);
}


all I am getting in the serial monitor is 228-229, no matter how much I move an object to and fro from the sensor the number doesnt change

Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8913
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The software looks right so the problem is probably in hardware.  Check your wiring.  Get a multimeter and check the voltage output of the sensor to see if it changes properly (connect to Gnd, +5, and meter between the signal line and Ground).  Try a different analog input pin (perhaps A0 has been damaged).
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

checked all of that and still the readings arent changing :-/
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8913
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So the meter is showing a changing output and none of the Arduino analog inputs shows the changing output?  Sounds like a fried ATmega chip.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: