mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-28 04:07:46 +00:00
22 lines
535 B
Python
22 lines
535 B
Python
from pybricks.pupdevices import Motor
|
|
from pybricks.parameters import Port
|
|
from pybricks.tools import wait
|
|
|
|
# Initialize a motor on port A.
|
|
example_motor = Motor(Port.A)
|
|
|
|
while True:
|
|
|
|
# Get the default angle value.
|
|
angle = example_motor.angle()
|
|
|
|
# Get the angle between 0 and 360.
|
|
absolute_angle = example_motor.angle() % 360
|
|
|
|
# Get the angle between -180 and 179.
|
|
wrapped_angle = (example_motor.angle() + 180) % 360 - 180
|
|
|
|
# Print the results.
|
|
print(angle, absolute_angle, wrapped_angle)
|
|
wait(100)
|