Hello, I’m brand new to arduino development and I’m currently trying to get valid MaxSonar-EZ4 sensor input. I’ve measured the voltage to make sure it is getting 5V, and the AN pin out is at 2.5V if I have the sensor covered up. The analog voltage also fluctuates as expected if I remove the tape and pan it around the room. However, no matter what I do, my arduino seems to report some random analog value around 203-250, regardless of where it is pointed. These random values also happen if don’t have anything connected to the arduino at all (if I disconnect the sensor and run the arduino without anything attached).
So it seems that the sensor is working properly from what I can tell, but I’m not getting good information from my arduino. I’m using an Arduino Duemilanove and a Lilypad, both with the same results. Here is the code that I am using:
You are right, bikeNomad, a quick test shows that setting the analog pin as a digital input doesn’t effect its ability to read an analog value. At least on my 3.3 volt 168 Pro.
The random values do point to a floating input as you have suggested.
Thank you so much for the suggestions bikeNomad and GeneW. I’m embarrassed to admit that I was plugging into the digital input pins instead of the analog. Definitely a facepalm moment. Everything works great now!