Distance Sensor False Values

The kids tried to do a programming routine with color sensors in robotC, but sometimes the robot acted weird. They thought it could be a lightning issue and si se we have no idea as of how is the lightning going to be at worlds they changed their programming to use distance sensors instead.

Now the problem they are having is inconsistency due to false readings on the sensor. The robot can be in the middle of the field and the sensor is constantly reading between 450s and 500 depending on the placement, but from time to time it reads a 180s value.

This affects the programming since they are trying to move to the 300s to make a drop but if it reads a smaller value than it really is it make cause to make the drop in the incorrect place. Is there anyway to make the values more consistent? Like waiting for values of 500 or less… so far what we are doing is asking the sensor and if the conditions meet, we wait 250 and ask again to make sure the value read was the correct one, but it makes us waste 3-6 seconds.

Hi. I think you may be able to use the setDistanceMaxRange and setDistanceMinRange. That may help remove the false positives. Also, you may have the the kids use code that gets them close to where they are wanting to make use of the sensors, then set those thresholds and use the sensors for fine tuning. Also, if the sensors aren’t close to a 90 degree angle to a flat surface/field edge or even placed to high, it may not accurately be able to bounce the sonor/sound back to the sensor for an accurate reading. you may need to have them fix the robot rotation before and after using the sensors.

We encountered both issues before.

For distance sensor, what you are seeing is normal (as of 2 yrs ago, highrise). There is a dead zone. I did not understand what the kid was trying to explain so I told him to use the debugger. He said that there was a place in the field the readings were not good and then picks up valid values after that. This was with default range settings as I told him to work with one setting at a time.

For the color sensor, the angle matters. Also helps to put it facing down or 45 degree angle downwards, using the LED on.