Exemple #1
0
def turnCycle():
    print("assad")
    # stop()
    # time.sleep(2)
    # forward()
    # time.sleep(0.5)
    stop()
    time.sleep(1)
    turnRight()
    time.sleep(0.33)
    stop()
def reroute(changepin):
    changePin = int(changepin) #cast changepin to an int

    if changePin == 1:
        motors.turnLeft()
    elif changePin == 2:
        motors.forward()
    elif changePin == 3:
        motors.turnRight()
    elif changePin == 4:
        motors.backward()
    else:
        motors.stop()

    response = make_response(redirect(url_for('index')))
    return(response)
Exemple #3
0
def reroute(changepin):

	changePin = int(changepin) #cast changepin to an int

	if changePin == 1:
		motors.turnLeft()
	elif changePin == 2:
		motors.forward()
	elif changePin == 3:
		motors.turnRight()
	elif changePin == 4:
		motors.backward()
	else:
		motors.stop()


	response = make_response(redirect(url_for('index')))
	return(response)
def reroute(changepin):

    changePin = int(changepin)

    if changePin == 1:
        motors.turnLeft()
    elif changePin == 2:
        motors.forward()
    elif changePin == 3:
        motors.turnRight()
    elif changePin == 4:
        motors.backward()
    elif changePin == 5:
        motors.stop()
    else:
        print("Wrong command")

    response = make_response(redirect(url_for('index')))
    return (response)
Exemple #5
0
        time.sleep(1)

        forward()
        time.sleep(2)
        stop()
        time.sleep(1)
        turnLeft()
        time.sleep(turnTiming)
        stop()
        time.sleep(1)

        forward()
        time.sleep(2)
        stop()
        time.sleep(1)
        turnRight()
        time.sleep(0.33)
        stop()
        time.sleep(2)
        forward()
        time.sleep(2)
        stop()
        time.sleep(1)
        turnLeft()
        time.sleep(0.33)
        stop()
        time.sleep(2)
        forward()
        time.sleep(2)
        stop()
        isForward = True
Exemple #6
0
import RPi.GPIO as GPIO
import time
import motors
import ultrasound
import sound

GPIO.setmode(GPIO.BCM)

# Main loop for polling dogbot sensors
##motors.reset()
GPIO.setup(21, GPIO.IN)
print (GPIO.input(21))

while(True):
    # Checks to see if switch to toggle freemode is on
    freeMode = (GPIO.input(21) == 1)
    while(freeMode):
        if(ultrasound.getDistance() < 80.0):
            motors.backup(.5)
            motors.turnRight(.364)
        else:
            motors.forward(.5)
        freeMode = (GPIO.input(21) == 1)
    if(ultrasound.getDistance() < 20.0):
        motors.turnLeft(.7234)
        sound.bark()

motors.GPIO.cleanup()
ultrasound.GPIO.cleanup()
exit()
Exemple #7
0
 if (currentDetection == "face"):
     if (time.time() > startTime + 10):
         motor_direction = "unsure"
     if (motor_direction == "left"):
         print("R")
         try:
             motors.turnLeft()
             time.sleep(3)
             motors.stopThere()
             currentMotorAction = "stop"
         except:
             print("")
     elif (motor_direction == "right"):
         print("L")
         try:
             motors.turnRight()
             time.sleep(3)
             motors.stopThere()
             currentMotorAction = "stop"
         except:
             print("")
         #sleep(0.3)
         #motor_direction = ""
     elif (motor_direction == "unsure" and firstRun == False):
         print("rotating")
         motors.turnRight()
         time.sleep(6)
         motors.stopThere()
         currentMotorAction = "stop"
     else:
         print("N")