def moveMotor(self, duticycle): self.PWMData = duticycle if duticycle > 5: self.forwwardMotion = 1 self.backwardMotion = 0 IO.output(self.inputLeftPin, IO.HIGH) IO.output(self.inputRightPin, IO.LOW)
def __init__(self,LPWMPin, RPWMPin): self.LPWMPin = LPWMPin #Pins initialization self.RPWMPin = RPWMPin #Pins initialization self.PWMData = 0 #PWM data self.forwwardMotion = 0 #0 means NO, 1 means yes self.backwardMotion = 0 #0 means NO, 1 means yes IO.setwarnings(False) IO.setmode(IO.BCM) IO.setup(LPWMPin, IO.OUT) self.LPWMctrl = IO.PWM(LPWMPin,100) self.LPWMctrl.start(0) IO.setup(RPWMPin,IO.OUT) self.RPWMctrl = IO.PWM(RPWMPin, 100) self.RPWMctrl.start(0)
def __init__(self,inputLeftPin, inputRightPin): self.inputLeftPin = inputLeftPin #Pins initialization self.inputRightPin = inputRightPin #Pins initialization self.forwwardMotion = 0 #0 means NO, 1 means yes self.backwardMotion = 0 #0 means NO, 1 means yes IO.setwarnings(False) IO.setmode(IO.BCM) # IO.setup(enablePin, IO.OUT) //EnablePin- NO NEED as Shorted to 5V # self.enablePinCtrl = IO.PWM(enablePin,100) # self.enablePinCtrl.start(0) IO.setup(inputLeftPin,IO.OUT) IO.setup(inputRightPin, IO.OUT)
def __init__(self,inputLeftPin, inputRightPin, enablePin): self.inputLeftPin = inputLeftPin #Pins initialization self.inputRightPin = inputRightPin #Pins initialization self.enablePin = enablePin #Pins initialization self.PWMData = 0 #PWM data self.forwwardMotion = 0 #0 means NO, 1 means yes self.backwardMotion = 0 #0 means NO, 1 means yes IO.setwarnings(False) IO.setmode(IO.BCM) IO.setup(enablePin, IO.OUT) self.enablePinCtrl = IO.PWM(enablePin,100) self.enablePinCtrl.start(0) IO.setup(inputLeftPin,IO.OUT) IO.setup(inputRightPin, IO.OUT)
IO.setup(inputLeftPin,IO.OUT) IO.setup(inputRightPin, IO.OUT) def moveMotor(self, duticycle): self.PWMData = duticycle if duticycle > 5: self.forwwardMotion = 1 self.backwardMotion = 0 IO.output(self.inputLeftPin, IO.HIGH) IO.output(self.inputRightPin, IO.LOW) elif duticycle < -5: self.forwwardMotion = 0 self.backwardMotion = 1 IO.output(self.inputLeftPin, IO.LOW) IO.output(self.inputRightPin, IO.HIGH) else: self.forwwardMotion = 0 self.backwardMotion = 0 IO.output(self.inputLeftPin, IO.LOW) IO.output(self.inputRightPin, IO.LOW) self.PWMData = abs(duticycle); self.enablePinCtrl.ChangeDutyCycle(self.PWMData) def printMotor(self,motorName): print(motorName,self.inputLeftPin,self.inputRightPin,self.enablePin,self.PWMData,self.forwwardMotion,self.backwardMotion) ####################################################################### #######################################################################