Introduction to the EV3


Flollow the instructions on the LEGO Education site to use Python on your EV3

  • download the microSD image to your computer
  • flash the image to the microSD card using a tool such as Etcher
  • insert the microSD card into EV3 brick
  • download the VS Code editor to your compouter
  • install the EV3 extensions

Get system information

In the EV3DEV device browser you have access to a context menu.


It allows you to :

  • open the SSH Terminal (entering automatically the password)
  • take a (color) screenshop of the EV3 display

This is the system info you get:

========== ev3dev-sysinfo ==========
Image file:         ev3-micropython-v1.0.0-sd-card-image
Kernel version:     4.14.96-ev3dev-2.3.2-ev3
Brickman:           0.10.0
BogoMIPS:           148.88
Board:              board0

Connect to the EV3 using ssh

You can connect to EV3 brick remoteyl via a SSH terminal. Click in the EV3DEV device browser to connect to the EV3. Open a terminal and connect via SSH to robot@ev3dev.local

The password is maker:

user@MacBook-Air brick % ssh robot@ev3dev.local
Warning: Permanently added the ECDSA host key for IP address 'fe80::16:53ff:fe60:1922%en4' to the list of known hosts.
Linux ev3dev 4.14.96-ev3dev-2.3.2-ev3 #1 PREEMPT Sun Jan 27 21:27:35 CST 2019 armv5tejl
            _____     _
_____   _|___ /  __| | _____   __
/ _ \ \ / / |_ \ / _` |/ _ \ \ / /
|  __/\ V / ___) | (_| |  __/\ V /
\___| \_/ |____/ \__,_|\___| \_/

Debian stretch on LEGO MINDSTORMS EV3!

Execute Linux commands

You can print the working directory:


Display the list of current folders:

brick  getting_started  sensors

Change directory to brick and display its content:

cd brick/
ls  brick.rst

Run a Python session

Run a Python session:

Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

Execute some Python commands:

>>> print('hello world')
hello world
>>> 99**12

Text to speech

From the command line you can start text-to-speech:

espeak "hello, I am an EV3.
> I like to talk because I am a robot.
> Did you know that robots like to make sounds?
> Beep. Boop. Dit. Dit. Meep.
> I am just such a chatterbox." --stdout | aplay

Update the system

You can update the Debian operating system:

sudo apt-get update

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for robot:

Demo example

This is a demo example for a simple Python program.

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor
from pybricks.parameters import Port

# Play a sound.

# Initialize a motor at port B.
test_motor = Motor(Port.B)

# 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.
# This time with a higher pitch (1000 Hz) and longer duration (500 ms).
brick.sound.beep(1000, 500)

Import classes and methods

These are all the useful classes and methods.

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import (Port, Stop, Direction, Button, Color,
                                 SoundFile, ImageFile, Align)
from import print, wait, StopWatch
from pybricks.robotics import DriveBase

Micro-python vs real Python

The first line of the program, the so-called shebang, indicates to the EV3 which Python it is going to use. LEGO proposes the use of Micropython, which is starting up slightly faster:

#!/usr/bin/env pybricks-micropython

To use real Python put this on your first line:

#!/usr/bin/env python3

You get bigger fonts and get text-to-speech.

#!/usr/bin/env python3
from ev3dev.ev3 import *
import os

os.system('setfont Lat15-TerminusBold14')
L = LargeMotor('outB'); mL.stop_action = 'hold'
R = LargeMotor('outC'); mR.stop_action = 'hold'

msg = 'Hello, my name is EV3!'

L.run_to_rel_pos(position_sp= 840, speed_sp = 250)
R.run_to_rel_pos(position_sp=-840, speed_sp = 250)