So a while a go I hooked up one of those sharp proximity sensors to my arduino. I ran a digital read, it went well… when i put my hand infront of the sensor the number got lower but when i moved my hand further the number got higher. Now when I hook it up the numbers change randomly and they only change a few numbers (up or down). I tried many things and i could not figure it out. The weird thing is that when the sensor is not even connected (or anything for that matter) the numbers still appear. Any ideas?
A digital read ? I thought these devices output an analog voltage. Which device do you have (link) ?
As far as the random reads, note the note below …
http://www.arduino.cc/en/Reference/DigitalRead
To eliminate that issue (assuming you need a digital input) read the tutorial re: pullup resistors …