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!
In VEXCode Blocks:
Print [distance7] distance in [mm]
And again, “no object” message is in Device Info with no program running.
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.
In a device info isn’t seeing that at all and something is wrong. When you update with vex os does it show a distance sensor there?
Sorry for multiple posts I’m on my phone. but do you have another distance sensor to try to see if it shows anything different on device info?
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.
get range value
(not near a device that I can write code)
If it isn’t working in Device Info on the Brain, its probably dead. I’ve had a couple of flakey distance sensors over the years.
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?
Either the reseller or VEX will be able to sort I would have thought.
Got it sorted out-- returned to the reseller. Thanks all!