Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98098
| X-Received | by 10.182.225.230 with SMTP id rn6mr18783338obc.20.1446471910460; Mon, 02 Nov 2015 05:45:10 -0800 (PST) |
|---|---|
| X-Received | by 10.50.8.68 with SMTP id p4mr182276iga.8.1446471910443; Mon, 02 Nov 2015 05:45:10 -0800 (PST) |
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!i2no2486835igv.0!news-out.google.com!z4ni43894ign.0!nntp.google.com!i2no2486825igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Mon, 2 Nov 2015 05:45:09 -0800 (PST) |
| In-Reply-To | <AyJZx.1$Gy4.0@fe40.am1> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=198.133.214.10; posting-account=QnRR_woAAABCN3o9NKfJV3oj6njOg5Qm |
| NNTP-Posting-Host | 198.133.214.10 |
| References | <d9hnjqF4lbuU1@mid.individual.net> <AyJZx.1$Gy4.0@fe40.am1> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <7bcb9d61-e610-47e3-9cba-35eba075e993@googlegroups.com> (permalink) |
| Subject | Re: GoPiGo script |
| From | hakugin.gin@gmail.com |
| Injection-Date | Mon, 02 Nov 2015 13:45:10 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:98098 |
Show key headers only | View raw
On Monday, November 2, 2015 at 8:29:26 AM UTC-5, input/ld...@casema.nl wrote:
> I tried to use def loop(): now for to restart the script.
> but its only restart "fwd()" print ("forward 1x") and then stop.
> It does not look further for the if function.
> Is there another way to restart this script ?
> I also tried with (while True:) but that does nothing.
>
> Thanks
<snip>
Try this: (hopefully the indentation is preserved)
from gopigo import *
from time import sleep
# Boolean variable for the "while" loop
KEEP_GOING = True
enable_servo()
mindist = 80
servo(90)
set_right_speed(150)
set_left_speed(105)
def MainLoop():
# A check statement can be added to set KEEP_GOING to False
# and allow the function to end
while KEEP_GOING:
mindist = 90
server(90)
fwd()
print("forward1x")
if mindist > us_dist(15):
bwd()
print("backward1x",us_dist(15)
sleep(2)
left_rot()
print("left rot",us_dist(15))
sleep(3)
stop()
if mindist < us_dist(15):
fwd()
print("forward2x",us_dist(15))
time.sleep(2)
stop()
# This is a simple check to determine if the script was run by itself
# or if it was imported by another script. If it was imported it will
# fail this check and not run the code but will allow access to the
# function defined above.
if __name__ == '__main__':
MainLoop()
- Mike
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
GoPiGo script input/ldompeling@casema.nl - 2015-10-30 16:58 +0000
Re: GoPiGo script Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-30 17:27 +0000
Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 13:29 +0000
Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 05:45 -0800
Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 05:49 -0800
Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 14:28 +0000
Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 07:19 -0800
Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-11-02 15:21 +0000
Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 07:30 -0800
Re: GoPiGo script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-02 09:10 -0500
Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 14:32 +0000
Re: GoPiGo script Robin Koch <robin.koch@t-online.de> - 2015-11-02 20:31 +0100
Re: GoPiGo script Larry Hudson <orgnut@yahoo.com> - 2015-11-02 13:06 -0800
Re: GoPiGo script Robin Koch <robin.koch@t-online.de> - 2015-11-03 01:45 +0100
Re: GoPiGo script hakugin.gin@gmail.com - 2015-10-30 10:32 -0700
Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-30 18:18 +0000
Re: GoPiGo script hakugin.gin@gmail.com - 2015-10-30 12:59 -0700
Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 10:28 +0000
Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 17:42 +0000
Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 18:59 +0000
Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 19:42 +0000
Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 20:18 +0000
Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 21:12 +0000
csiph-web