Hello.... im newby here.... but im working with some small project.
Basically just i want to control motor on...
1. Wait for "R" key to start motor run
2. Stop until button is pressed
3. Wait for "R" to continue run.
looks simple??? soryy but i cant make it.
This is what i got.
Basically just i want to control motor on...
1. Wait for "R" key to start motor run
2. Stop until button is pressed
3. Wait for "R" to continue run.
looks simple??? soryy but i cant make it.
This is what i got.
Code:
import RPi.GPIO as GPIOimport timein1=24in2=23en=25GPIO.setmode(GPIO.BCM)GPIO.setup(22,GPIO.IN,pull_up_down=GPIO.PUD_DOWNGPIO.setup(in1,GPIO.OUT)GPIO.setup(in2,GPIO.OUT)GPIO.setup(en,GPIO.OUT)p=GPIO.PWM(en,1000)p.start(50)while True: if input()=='r' print("run") GPIO.output(in1,GPIO.HIGH) GPIO.output(in2,GPIO.LOW) elif GPIO.input(22)==GPIO.HIGH: GPIO.output(in1,GPIO.LOW) GPIO.output(in2,GPIO.LOW) print ("stop")
Statistics: Posted by Gantonio — Wed May 29, 2024 6:14 am