Hello, We have a slight problem, during autonomous, we are using the ultrasonic range finder so that the robot doesn’t bump into the perimeter, the goal perimeter or other robots but for some reason do not seem to work. How can that be fixed?
We’re having a similar issue. Not sure as to what the cause is yet. However if a wait command is placed before the reading the sonar sensor value, then the sensor will work. But, the wait time only seems to work with a value greater than 50 ms.
Could you perhaps include the rest of your code, and explain exactly how it is behaving? My first guess would be that you are not setting the motors to a power of 0 after this while loop, but without the rest of the code, I’m left to making guesses.
Okay so describe the behavior you are seeing when you run this code. What doesn’t work? Is it that the motors never stop? If so I would suggest putting a StopAllMotors(); between the close bracket for the while loop and the close bracket of task autonomous.
If you live watch the values by running the ROBOTC debugger does the value of the sonar sensor ever change? If not then check the order of the wires being plugged and check it matches Motor and Sensor Setup.
So when the autonomous code is run, the robot gets close to the field perimeter but doesn’t stop and collides with the perimeter. I am not sure, but if i do remember correctly, the ultrasonic sensor value does change when it detects something.