On Wed, Jun 15, 2016 at 11:00 AM, MRAB <pyt...@mrabarnett.plus.com> wrote: > On 2016-06-15 15:15, ldompel...@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 ... > approximately ...) > > -- > https://mail.python.org/mailman/listinfo/python-list
This reminds me of a toy called 'Big Trak' made by Milton Bradley in the 1980s https://en.wikipedia.org/wiki/Big_Trak -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list