ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

How do I create a program that runs a motor forever at a specific RPM? #778

Open FinnThom opened 2 years ago

FinnThom commented 2 years ago

I tried using SpeedRPM with run_forever, but I can't figure out what the code should look like.

KooshaKayani commented 2 years ago
#!/usr/bin/env pybricks-micropython

from pybricks.ev3devices import InfraredSensor, Motor, ColorSensor
from pybricks.parameters import Port, Button, Color, ImageFile, SoundFile, Stop
from pybricks.tools import wait
from pybricks.robotics import DriveBase
from pybricks.hubs import EV3Brick 

# Initialize the EV3 Brick.
ev3 = EV3Brick()

# Initialize the motors.
motor = Motor(Port.C)

while True:
    motor.run(speed)