Could someone help me with a NameError that I can't seem to figure out. The program asks for an input and then runs two DC motors. It worked for a while and then when I reopened the program today I keep getting this error. Thank you. -Bryan
import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) Motor1A = 16 Motor1B = 18 Motor1E = 22 Motor2A = 11 Motor2B = 13 Motor2E = 15 GPIO.setup(Motor1A,GPIO.OUT) GPIO.setup(Motor1B,GPIO.OUT) GPIO.setup(Motor1E,GPIO.OUT) GPIO.setup(Motor2A,GPIO.OUT) GPIO.setup(Motor2B,GPIO.OUT) GPIO.setup(Motor2E,GPIO.OUT) forward = ['f', 'F'] backward = ['b', 'B'] exit_ = ['e', 'E'] print('Which direction would you like to move?') direction = input("Type 'f' for forward, 'b' for backward, or 'e' to exit: ") while direction not in exit_: if direction in forward: print('Moving Forward!') GPIO.output(Motor1A,GPIO.HIGH) GPIO.output(Motor1B,GPIO.LOW) GPIO.output(Motor1E,GPIO.HIGH) GPIO.output(Motor2A,GPIO.HIGH) GPIO.output(Motor2B,GPIO.LOW) GPIO.output(Motor2E,GPIO.HIGH) sleep(2) print ("Stopping!") GPIO.output(Motor1E,GPIO.LOW) GPIO.output(Motor2E,GPIO.LOW) if direction in backward: print('Moving Backward!') GPIO.output(Motor1A,GPIO.LOW) GPIO.output(Motor1B,GPIO.HIGH) GPIO.output(Motor1E,GPIO.HIGH) GPIO.output(Motor2A,GPIO.LOW) GPIO.output(Motor2B,GPIO.HIGH) GPIO.output(Motor2E,GPIO.HIGH) sleep(2) print ("Stopping!") GPIO.output(Motor1E,GPIO.LOW) GPIO.output(Motor2E,GPIO.LOW) sleep(1) print('Which direction would you like to move?') direction = input("Type 'f' for forward, 'b' for backward, or 'e' to exit: ") print('done') _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor