I have tried that too but apparently it doesn't work. I switched back to raspi 4 because raspi 5 doesn't have a lib where it will use the dir as intended like in RPi.GPIO libPerhaps I may be misunderstanding your code, but I don't see where the code changes the state of the direction pin.
I seeBut in set_direction, I don't see anything that affects the output device.Code:
direction = OutputDevice(dir_pin, active_high=True) # Active high to rotate CW
If you change the code snippet above toThe motor will most likely go in the reverse direction.Code:
direction = OutputDevice(dir_pin, active_high=False) # Active low to rotate CCW
Code:
def spin_motor(direction_pin, pulse_pin, enable_pin, direction, steps): GPIO.output(enable_pin, GPIO.LOW) # Enable motor GPIO.output(direction_pin, cw_direction_1 if direction == "CW" else ccw_direction_1) for _ in range(steps): GPIO.output(pulse_pin, GPIO.HIGH) sleep(0.0001) GPIO.output(pulse_pin, GPIO.LOW) sleep(0.0005) GPIO.output(enable_pin, GPIO.LOW) # Disable motor after spin
Statistics: Posted by XGTFrostKing — Sat Dec 14, 2024 7:24 pm