mirror of
https://github.com/kevinveenbirkenbach/erinaco.git
synced 2025-09-09 19:57:16 +02:00
Zwischenstand Motorenimplementierung
This commit is contained in:
1
aktoren/__init__.py
Normal file
1
aktoren/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
BIN
aktoren/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
aktoren/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
aktoren/__pycache__/motor.cpython-36.pyc
Normal file
BIN
aktoren/__pycache__/motor.cpython-36.pyc
Normal file
Binary file not shown.
21
aktoren/motor.py
Normal file
21
aktoren/motor.py
Normal 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)
|
||||
|
Reference in New Issue
Block a user