mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2024-11-23 14:31:04 +01:00
22 lines
681 B
Python
22 lines
681 B
Python
import RPi.GPIO as GPIO
|
|
class Motor(object):
|
|
def __init__(self,directionPin,speedPin,directionForward):
|
|
self.directionPin=directionPin #BCM-Pin
|
|
self.speedPin=speedPin #BCM-Pin
|
|
self.directionForward=directionForward; #Enthaelt einen BOOL
|
|
self.changeSpeed(0)
|
|
GPIO.setup(self.directionPin, GPIO.OUT)
|
|
GPIO.setup(self.speedPin, GPIO.OUT)
|
|
self.stop()
|
|
def forward(self):
|
|
GPIO.output(self.directionPin,self.directionForward)
|
|
GPIO.output(self.speedPin,1)
|
|
def backward(self):
|
|
GPIO.output(self.directionPin,(not self.directionForward))
|
|
GPIO.output(self.speedPin,1)
|
|
def changeSpeed(self,speed):
|
|
self.speed=speed
|
|
def stop(self):
|
|
GPIO.output(self.speedPin, 0)
|
|
|