def findTribble() : print "findTribble()" tribbleFound = 0 move.spinLeftNoStop() while not tribbleFound : sleep(0.2) pos = sensor.getRedPosition() print "Pos: ", pos if pos > 0: move.stop() tribbleFound = 1 print "found Tribble..."
while True: distance = ultrasonicSensor.measureDistance() # ultra sensor replies the distance back print('distance= ', distance) # If vehicle pass 2 obstacles, it will drive 1 more second and stop. if obstacle == 3: movement.go_forward(70, 1) movement.pwm_low() break # when the distance is above the dis, moving object forwards elif distance > dis: movement.go_forward_infinite(70) # when the distance is below the dis, moving object stops else: # stop and wait 1 second movement.stop() time.sleep(1) # select type of turn if obstacle == 1: turning.leftPointTurn(PointPr, PointTr) obstacle += 1 else: turning.leftSwingTurn(SwingPr, SwingTr) obstacle += 1 # after turning, stop and wait 0.3 second movement.stop() time.sleep(0.3) # when the Ctrl+C key has been pressed, # the moving object will be stopped
def doSomething() : print "doSomething()" move.spinLeftNoStop() move.armDown() move.armUp() move.stop()
import brickpi3 from movement import stop stop()