examples/pup/motor_dc: Add battery box example.

This commit is contained in:
Laurens Valk
2021-05-21 14:00:57 +02:00
parent 73cc441edb
commit 3b20a811cb
2 changed files with 19 additions and 0 deletions
+6
View File
@@ -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)