Zwischenstand Motorenimplementierung

This commit is contained in:
Kevin Frantz
2017-04-15 00:42:23 +00:00
parent 88f0075735
commit 3df8ab165a
15 changed files with 132 additions and 6 deletions

1
aktoren/__init__.py Normal file
View File

@@ -0,0 +1 @@

Binary file not shown.

Binary file not shown.

21
aktoren/motor.py Normal file
View File

@@ -0,0 +1,21 @@
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)