import RPi.GPIO as GPIO
#import distance as abstand
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
rv = 10 #rechte Rad vorwärts
rz = 9 #rechte Rad rückwärts
rpwm = 25 #rechte Rad Geschwindigkeit
lv = 17 #linke Rad vorwärts
lz = 27 #linke Rad rückwärts
lpwm = 24 #linke Rad Geschwindigkeit
en = 22 #Motortreiber aktivieren
GPIO.setup(rv,GPIO.OUT)
GPIO.setup(rz,GPIO.OUT)
GPIO.setup(lv,GPIO.OUT)
GPIO.setup(lz,GPIO.OUT)
GPIO.setup(en,GPIO.OUT)
GPIO.setup(rpwm,GPIO.OUT)
GPIO.setup(lpwm,GPIO.OUT)
GPIO.output(en, True)
pwmr = GPIO.PWM(rpwm, 50)
pwmr.start(0)
pwml = GPIO.PWM(lpwm, 50)
pwml.start(0)
def vor():
GPIO.output(rv, True)
GPIO.output(lv, True)
GPIO.output(rz, False)
GPIO.output(lz, False)
pwml.ChangeDutyCycle(100)
pwmr.ChangeDutyCycle(100)
Lesezeichen