What we see in main.py Pro Preview

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1522
  • 28 Jan 2020
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.

# Create your objects here.
ev3 = EV3Brick()

# Write your program here.
ev3.speaker.beep()

The entire code between the green lines introduce commands that we can use below them. We will look at them in-depth later on.

The green lines of code are comments that are not executed when the programs start. When we place the "#" symbol at the beginning of a line, everything on that line is considered a comment and is not executed by the program. This allows us to take notes within the code file.

The last line in the code "brick.sound.beep()" is the command for playing a "Beep" sound. We leave it in the program to know when the program has begun executing. You must begin every program you make after the "ev3.speaker.beep()" command.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Python with LEGO Mindstorms EV3 - Level 1
  • 74
  • 28:18
  • 114
Image for Lesson 1 - Beverage Assistant
  • 14
  • 4
  • 6
  • 3d_rotation 1