class DC: def __init__(self): """ DC maps DragonBoard 410c GPIO pins for Debian to the L293N H-Bridge I/C, ready to receive control messages from Manager.py. Green wire : Pin 23 -> OpAmp Node 1 -> L298N h-bridge Input 2 White wire : Pin 24 -> OpAmp Node 4 -> L298N h-bridge Enable A Yellow wire : Pin 26 -> OpAmp Node 3 -> L298N h-bridge Input 1 Set Input 2 to Low, Input 1 to High for clockwise spin. """ self.gp = GPIOProcessor() # h-bridge self.green = self.gp.getPin23() self.white = self.gp.getPin24() self.yellow = self.gp.getPin26() self.green.out() self.white.out() self.yellow.out() # clockwise self.green.low() # Input 2 self.yellow.high() # Input 1 self.isPropSpinning = False def start_motor(self): """ Set Enable A to High to start motor. :rtype: Boolean :return: True if motor started, False if failed. """ try: self.white.low() self.white.high() self.isPropSpinning = True return True except KeyboardInterrupt(): print "Keyboard interrupt received. Cleaning up ..." self.gp.cleanup() return False def stop_motor(self): """ Set Enable A to Low to stop motor. :rtype: Boolean :return: True if motor stopped, False if failed. """ try: self.white.low() self.isPropSpinning = False return True except KeyboardInterrupt(): print "Keyboard interrupt received. Cleaning up ..." self.gp.cleanup()
from GPIOLibrary import GPIOProcessor import time GP = GPIOProcessor() try: Pin23 = GP.getPin23() Pin23.out() Pin25 = GP.getPin25() Pin25.out() Pin27 = GP.getPin27() Pin27.out() Pin31 = GP.getPin31() Pin31.out() print("Pins are set to output") for i in range(0, 20): if Pin23.getValue() == 1: Pin23.low() Pin25.high() elif Pin25.getValue() == 1: Pin25.low() Pin27.high() elif Pin27.getValue() == 1: Pin27.low() Pin31.high() elif Pin31.getValue() == 1:
import socket # import time MAGIC = "face600d" server_socket = socket.socket() server_host = '192.168.43.20' server_port = 5002 server_socket.bind((server_host, server_port)) server_socket.listen(5) c,addr = server_socket.accept() try: # Stepper Motor Controls A1 = GP.getPin23() # blue A2 = GP.getPin24() # pink B1 = GP.getPin25() # yellow B2 = GP.getPin26() # orange A1.out() A2.out() B1.out() B2.out() # Delay time T = 0.001 # Stepper Sequence (Forward ; Reverse) SS = [[[1,1,0,0],[0,1,1,0],[0,0,1,1],[1,0,0,1]], [[1,0,0,1],[0,0,1,1],[0,1,1,0],[1,1,0,0]]]