GoPiGo distence sensor
python at mrabarnett.plus.com
Wed Jun 15 11:00:10 EDT 2016
On 2016-06-15 15:15, ldompeling at casema.nl wrote:
> I have a small robot on wheels named the GoPiGo.
> What I want is if the distence sensor read the same distence for let say 5 seconds then the GoPiGo go's backward.
> But I don't now how to program this in python.
> The Api functions for the GoPiGo are here: http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the-raspberry-pi-gopigo/
> Can someone help me with this.
Check the distance at regular intervals, like the ticks of a clock.
At each tick, check the distance.
If the distance is the same as the previous measurement, increment a
counter, else reset the counter.
If the counter reaches a certain value, it means that the robot has been
at that distance for that many ticks. (If it checks every second and the
counter reaches 5, then it has been at that distance for 5 seconds ...
More information about the Python-list