I have a distance sensor fresh out of the box, and it doesn’t seem to be reading properly. I have a basic program running “print distance in mm” and I get what appears to be a garbage value: 4294967295.429467295 (note same number before and after decimal). In Device Info, port reads “Distance Sensor, Distance No Object.” Neither change if I put wall / hand / whatever in front of it.
All components updated to v2.1.3 (with sensor connected during updating). Using VEXCode blocks. Thanks!
You’re going to need to put it in a forever loop. You also need to have it returned to position one one. in general when you post the code if you could take a screenshot that will give us a better idea but I think I got it from what you typed.
If you are writing to the screen you need to remember to clear it before you write the text. Otherwise it writes over and over in the same spot. It makes you think you are getting strange responses.
But like @sankeydd said, you need to be in a forever loop.
forever
clear screen
get range value
print value
end
Thanks all-- I did try it with a forever loop as well to no avail. I also wrote a very simple “drive straight until distance is less than 200 mm then stop motor” program that failed as the robot drove straight into the wall. The code from that one is in my office so I can’t drop it in, unfortunately.
If the sensor is truly shot, do I go back to the regional retailer on that one, or to VEX directly?