lReverse = True lForward = False if y < -2: if not lForward: MotorDrive.forward() lReverse = False lForward = True conn.sendall('') conn.close() MotorDrive.stop () #----------------------------------------------------------- MotorA = motordrive.motorDriver(7,11,15,12) HOST = '' # Symbolic name meaning all available interfaces PORT = 8875 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print 'Socket created' s.settimeout(10) try: s.bind((HOST, PORT)) except socket.error , msg: print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1] #sys.exit() print 'Socket bind complete'
import RPi.GPIO as GPIO import time import motordrive GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) m = motordrive.motorDriver(7,11,13,12) m.start() m.forward() time.sleep(3) m.reverse() time.sleep(3) m.stop()