import serial import RPi.GPIO as GPIO M1=13 M2=6 M3=7 M4=12 GPIO.setmode(GPIO.BCM) GPIO.setup(M1,GPIO.OUT) GPIO.setup(M2,GPIO.OUT) GPIO.setup(M3,GPIO.OUT) GPIO.setup(M4,GPIO.OUT) port = serial.Serial("/dev/ttyAMA0", baudrate=9600, timeout=1) data1=" " data=" " def left(): #left print("forward") GPIO.output(M1, True) GPIO.output(M2, False) GPIO.output(M3, True) GPIO.output(M4, False) def right(): print('backward') GPIO.output(M1, False) GPIO.output(M2, True) GPIO.output(M3, False) GPIO.output(M4, True) def backward(): print('right') GPIO.output(M1, False) GPIO.output(M2, True) GPIO.output(M3, True) GPIO.output(M4, False) def forward(): print('left') GPIO.output(M1, True) GPIO.output(M2, False) GPIO.output(M3, False) GPIO.output(M4, True) def stop(): print('stop') GPIO.output(M1, True) GPIO.o