EasyManua.ls Logo

LEGO MINDSTORMS Education EV3 - Page 15

LEGO MINDSTORMS Education EV3
17 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
13
Getting Started with LEGO
®
MINDSTORMS
®
Education EV3 MicroPython
Version 2.0.0
Figure 2.7: The EV3 Brick with a Large Motor attached to Port B.
Next, edit main.py so that it looks like this:
This program makes your robot beep, rotate the motor and beep again at a higher-pitched tone.
Runthe program to make sure it works as you expected.
Port B
Large Motor
LEGO, the LEGO logo and MINDSTORMS are trademarks of the LEGO Group.
©2019-2020 The LEGO Group.
#!/usr/bin/env pybricks-micropython
from
pybricks.hubs
import
EV3Brick
from pybricks.ev3devices
import
Motor
from pybricks.parameters
import
Port
# Initialize the EV3 brick.
ev3 = EV3Brick()
# Initialize a motor at port B.
test_motor = Motor(Port.B)
# 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(1000,
500)

Other manuals for LEGO MINDSTORMS Education EV3

Related product manuals