[Python] reverse direction brushless motor with raspberry pi

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Raspberry PI 4. I am trying to connect my raspberry pi with two brushless motors using ESC blheli 30a. They start spinning when I run the code. Is there a way to make it spin in the reverse direction with a python script?

    import time
    import RPi.GPIO as GPIO
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)

    GPIO.setup(7, GPIO.OUT)
    GPIO.setup(11, GPIO.OUT)
    t1 = GPIO.PWM(7, 50)
    t2 = GPIO.PWM(11, 50)
    t1.start(0)
    t2.start(0)

    def forward():
    print('forward')
    t1.ChangeDutyCycle(5.5)
    t2.ChangeDutyCycle(5.5)
    forward()
    x = input('enter: ')

    if x == 's':
    t2.stop()
    t1.stop()

    GPIO.cleanup()
    quit()

    Continue reading...

Compartilhe esta Página