mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-28 04:07:46 +00:00
examples/pup/motor_dc: Add battery box example.
This commit is contained in:
@@ -26,6 +26,12 @@ Motors without Rotation Sensors
|
||||
Examples
|
||||
-------------------
|
||||
|
||||
Making a train drive forever
|
||||
************************************
|
||||
|
||||
.. literalinclude::
|
||||
../../../examples/pup/motor_dc/motor_dc_battery_box.py
|
||||
|
||||
Making the motor move back and forth
|
||||
************************************
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from pybricks.pupdevices import DCMotor
|
||||
from pybricks.parameters import Port
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Initialize the motor.
|
||||
train_motor = DCMotor(Port.A)
|
||||
|
||||
# Choose the "power" level for your train. Negative means reverse.
|
||||
train_motor.dc(50)
|
||||
|
||||
# Keep doing nothing. The train just keeps going.
|
||||
while True:
|
||||
wait(1000)
|
||||
Reference in New Issue
Block a user