Beispiel #1
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)
Beispiel #2
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)
Beispiel #4
0
turnTiming = 0.41

while True:
    if isForward != True:
        forward()
        # while True:
        #     if Sonar():
        #         break
        time.sleep(2)
        turnCycle()
        forward()
        time.sleep(2)
        stop()
        time.sleep(1)
        turnLeft()
        time.sleep(turnTiming)
        stop()
        time.sleep(1)
        forward()
        time.sleep(2)
        stop()
        time.sleep(1)
        turnLeft()
        time.sleep(turnTiming)
        stop()
        time.sleep(1)

        forward()
        time.sleep(2)
        stop()
Beispiel #5
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()
Beispiel #6
0
if __name__ == "__main__":
    t2 = Thread(target=runB)
    t2.setDaemon(True)
    t2.start()

    try:
        while True:
            firstRun == False
            currentDetection = "face"
            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)