from gopigo import *
import time
#Distance from obstacle where the GoPiGo should stop : 20cm
distance_to_stop=20
print "Press ENTER to start"
#Wait for input to start
raw_input()
#Start moving
fwd()
while True:
#Find the distance of the object in front
#The pin for the ultrasonic sensor should be pin 15 (Analog Port A1)
dist=us_dist(15)
print "Dist:",dist,'cm'
#If the object is closer than the "distance_to_stop" distance, stop the GoPiGo
if dist
|