my first script for the GoPiGo

MRAB python at mrabarnett.plus.com
Thu Oct 22 12:40:45 EDT 2015


On 2015-10-22 16:45, input/ldompeling at casema.nl wrote:
> In reply to "MRAB" who wrote the following:
>
>> On 2015-10-22 16:07, input/ldompeling at casema.nl wrote:
>> > I want that this script runs to times from the upper line to the buttom
>> > line.
>> > I tried with for x in range(2): but that didn't work
>>
>> You say "didn't work", but in what way didn't it work?
>>
>> > The GoPiGo is a small robot on wheels.
>> >
>> > The API codes are here:
>> > http://www.dexterindustries.com/GoPiGo/programming/
>> > python-programming-for-the-
>> > raspberry-pi-gopigo/
>> >
>> >
>> > from gopigo import *
>> > import time
>> >
> Thanks or the reply.
>
> I mean that i want this script running two times.
> So the first line is mindist = 70
> And the last line is print x
> And that two times
> So that the robut continues moving two times in this script, from the upperline
> to the bottum line two times.
>
Then just indent those lines and precede them with the 'for' line.
>
>> > for x in range (2):
>>
>> The lines to be repeated should be indented more than the 'for' line.
>>
>> > mindist = 70
>> > servo(120)
>> > time.sleep(2)
>> > fwd()
>> > stop()
>> > time.sleep(2)
>> > bwd()
>> > stop()
>> > if mindist > us_dist(15):
>> >      bwd()
>> >      stop
>> >      print x
>> >




More information about the Python-list mailing list