GoPiGo2 Ultrasonic Sensor problems

I bought an ultrasonic sensor from this site, and tried to get it to work to no avail. Searching for my problem led to this thread, which told me to use the code found here to test it. I tested both the analog and digital ports, remembering to switch the variable when changed, yet always failed to get a accurate result. The vast majority of the time it would spit out 0, and the occasional -1. Rarely it would error with a “TypeError: ‘int’ object is not iterable”, with a few other values like 65280 making a brief appearance for one loop. Could anybody help me with this problem?

1 Like

Hello @kevin9sd,

Questions like this are best addressed at support@modrobotics.com

Can you let us know what robot you have ? (GoPiGo2 or 3?) And an example of your code?

1 Like

. . . Though it would be both interesting and instructive to know what happened.

I have a GoPiGo2 and the code I used was directly copy pasted from the example code linked at https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/sensor_examples/grove_distance_sensor.py