Hallo,
Ich habe ein Problem.
Ich habe ein Motor dc Motor am pi hängen und möchte jetzt auch ein Display mittels dpi Schnittstelle anschließen allerdings ist gpio 25 schon von dem Motor belegt.
Leider sehe ich im Code auch Nix was ich abändern kann. Gpio 25 bringt den Motor zum laufen.
Was kann ich tun?
Grüße
Ich habe ein Problem.
Ich habe ein Motor dc Motor am pi hängen und möchte jetzt auch ein Display mittels dpi Schnittstelle anschließen allerdings ist gpio 25 schon von dem Motor belegt.
Leider sehe ich im Code auch Nix was ich abändern kann. Gpio 25 bringt den Motor zum laufen.
Code:
import RPi.GPIO as GPIO from time import sleepin1 = 24in2 = 23en = 25temp1=1GPIO.setmode(GPIO.BCM)GPIO.setup(in1,GPIO.OUT)GPIO.setup(in2,GPIO.OUT)GPIO.setup(en,GPIO.OUT)GPIO.output(in1,GPIO.LOW)GPIO.output(in2,GPIO.LOW)p=GPIO.PWM(en,1000)p.start(25)print("\n")print("The default speed & direction of motor is LOW & Forward.....")print("r-run s-stop f-forward b-backward l-low m-medium h-high e-exit")print("\n") while(1): x=raw_input() if x=='r': print("run") if(temp1==1): GPIO.output(in1,GPIO.HIGH) GPIO.output(in2,GPIO.LOW) print("forward") x='z' else: GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.HIGH) print("backward") x='z' elif x=='s': print("stop") GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.LOW) x='z' elif x=='f': print("forward") GPIO.output(in1,GPIO.HIGH) GPIO.output(in2,GPIO.LOW) temp1=1 x='z' elif x=='b': print("backward") GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.HIGH) temp1=0 x='z' elif x=='l': print("low") p.ChangeDutyCycle(25) x='z' elif x=='m': print("medium") p.ChangeDutyCycle(50) x='z' elif x=='h': print("high") p.ChangeDutyCycle(75) x='z' elif x=='e': GPIO.cleanup() break else: print("<<< wrong data >>>") print("please enter the defined data to continue.....")
Was kann ich tun?
Grüße
Statistics: Posted by Marcel24 — Sat Apr 20, 2024 8:11 pm — Replies 2 — Views 36