Files
pybricks-api/examples/ev3/getting_started/main.py
T
Laurens Valk b0ffb24a2e examples: import snippets from pybricks-projects
These code samples are rendered in the docs, so we include them here.

For the git history of these snippets, see:
https://github.com/pybricks/pybricks-projects/commits/f4914069aaacfd9ab1e0dd6f05524f62cfc56b29/snippets
2020-11-04 10:17:33 +01:00

24 lines
529 B
Python

#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.parameters import Port
# Create your objects here
# Initialize the EV3 Brick.
ev3 = EV3Brick()
# Initialize a motor at port B.
test_motor = Motor(Port.B)
# Write your program here
# Play a sound.
ev3.speaker.beep()
# Run the motor up to 500 degrees per second. To a target angle of 90 degrees.
test_motor.run_target(500, 90)
# Play another beep sound.
ev3.speaker.beep(frequency=1000, duration=500)