New: A Udemy course for EV3 Python!    

Do you own a Lego EV3 robot? Are you happy programming it with Lego's quirky icon-based system, or would you like to learn to program it with a textual programming language, the kind professional coders use? If you want to program the EV3 with a textual programming language then Python has to be your best choice, for as well as being modern, concise and powerful, it's also probably the most popular and most taught textual programming language in the world! 

You can get some information about programming the EV3 with Python on this site,, but if you are looking for a proper step-by-step course then you will be pleased to learn that I have published on (in June 2019) a course on programming the EV3 with EV3dev Python. The Udemy course can be found at

Whether you choose to take the Udemy course or try to get started using only this site, there are some important points to note:
  • Neither this site nor the Udemy course will teach you the basics of Python, which you should of course know before you attempt using Python to control robots. You should learn the basics of Python elsewhere before taking the Udemy course or trying to use this site.
  • Both this site and the Udemy course focus on a particularly easy way to write and run Python scripts on the EV3, which is to use Microsoft Visual Studio Code, a free and very popular code editor that is available for Windows, MacOS and Linux. An EV3 extension is available for Visual Studio Code that makes the EV3 programming workflow particularly simple and efficient, once everything is set up correctly.
  • This site and the Udemy course focus on EV3dev Python. There are other versions of Python out there such as EV3 MicroPython, but as the name suggests, that is based on a more limited version of Python that does not offer features such as speech synthesis.
Want to know more about the Udemy course?
  • it's a substantial step-by-step course based on about 20 videos totaling around 5 hours. English subtitles are available for all the videos.
  • The course is compatible with both the home and education versions of the EV3.
  • In addition to the videos, the course includes:
    • A ZIP file containing almost all the scripts discussed in the course as well as sound and image files.
    • A PDF document (about 100 pages) that is essentially the script of all the videos.
    • Build instructions for the home version of the Education Vehicle model and links to build instructions for the education version.
    • Build instructions for an original drawing / writing robot for both the home and education versions.
    • A troubleshooting document.
  • Since the Udemy course is not quite free, you can expect me to give you personal help if you need it, something you cannot reasonably expect from a free site such as this one.
  • It's Udemy, so if you're not satisfied you can easily get your money back.
  • The Udemy course proposes a slightly simpler EV3 Python programming workflow than that proposed on this site. Specifically, it proposes a workflow that does not require you to have configuration files in the folder that holds your Python scripts.
  • The Udemy course can be found at
Watch this 10 minute video whether or not you are interested in the Udemy course. It will make you more certain than every that learning to program the EV3 with Python is a very smart move.

As previously stated, both this site and the Udemy course are focused on using Microsoft Visual Studio Code (VS Code) with the EV3 extension since this is by far the easiest way to write and run EV3 Python scripts. VS Code is a free code editor that runs on Windows, macOS and Linux. It should not be confused with Microsoft Visual Studio which is not free and which runs only on Windows. To learn more about working with VS Code click HERE. Note that the EV3 extension for VS Code is compatible only with 'Stretch' versions of ev3dev and not 'Jessie' versions so when you download ev3dev be sure to download the latest Stretch version and not the Jessie version.

The Lego Mindstorms EV3 robot is a very popular educational / entertainment robot that is normally programmed using an icon-based programming system that resembles Scratch. Read more about icon-based Lego EV3 programming on my site But the EV3 has a Linux computer at its heart and can therefore be programmed using a number of other programming systems such as Python, C++, Java or EV3 Basic (see my site Running these more advanced programming languages allows you to get your EV3 robot to do things that would not be possible with the standard EV3 programming system, such as making the EV3 speak whatever English words you want or making this drawing robot which uses EV3 Python:

This site is not intended to show you how to make programs as complex as the one above, only to help you get started with EV3 Python programming by working with very short, simple, easy-to-understand programs, or 'scripts'. But maybe one day you will be able to make your own programs as impressive as the one above.

In addition to empowering you to write programs that can do things that cannot be achieved with the standard icon-based EV3 programmings system, another great reason to learn EV3 Python is that EV3 Python is a textual programming language, the kind professional programmers use. Learning a textual programming language (especially Python) can boost your career prospects enormously, whereas learning to program the EV3 with the standard icon-based system will have much less value professionally.

If you are not sure which programming system you should be using to program the EV3 then follow this link. If you are sure that you want to use Python to program the EV3 then read on...

You're probably curious about what an EV3 Python program looks like. Here is an example which uses a color sensor to help a rover-type vehicle to follow a black line. This is just to give you a glimpse of an EV3 Python script - the full explanation is on THIS PAGE. This program does however include comments (preceded each time by an '#' sign) which are there solely to help you understand the code. The very first line is a special line called a  'shebang' which tells the EV3 to use the Python 3 interpreter to run the program and where to find Python 3 in the EV3's file hierarchy.

#!/usr/bin/env python3
# An EV3 Python (library v2) solution to Exercise 3
# of the official Lego Robot Educator lessons that
# are part of the EV3 education software

from ev3dev2.motor import MoveTank, OUTPUT_B, OUTPUT_C
from import ColorSensor
from ev3dev2.button import Button
from time import sleep

btn = Button() # we will use any button to stop script
tank_pair = MoveTank(OUTPUT_B, OUTPUT_C)

# Connect an EV3 color sensor to any sensor port.
cl = ColorSensor()

while not btn.any():    # exit loop when any button pressed
    # if we are over the black line (weak reflection)
    if cl.reflected_light_intensity<30:   
        # medium turn right
        tank_pair.on(left_speed=50, right_speed=0)
    else:   # strong reflection (>=30) so over white surface
        # medium turn left
        tank_pair.on(left_speed=0, right_speed=50)
    sleep(0.1) # wait for 0.1 seconds

EV3 Python needs to run with the support of the EV3dev operating system. The official site of EV3dev and EV3dev Python is and I will refer you to that site for the details of the installation and the documentation of the various EV3 Python functions. The developers of EV3dev and EV3dev Python have done a fantastic job making available a stable operating system and robot-related Python commands with the simplest possible syntax.

Unlike some of the developers of EV3dev, I'm not a professional coder, but I do have decades of experience teaching computer science to teens, including Python and EV3. I therefore feel well qualified to help people who already know the basics of Python and who want to start using EV3 Python to control their Lego EV3 robot. This site is in no way endorsed by Lego Corporation.

Since I'm a professional teacher, I'm especially keen to help other teachers begin using EV3 Python in the classroom. That's why there's a strong emphasis on coding on this site as opposed to building different models, fun though that may be. This site adopts the official 'Educator Vehicle' (also called the 'Driving Base') so nearly all the scripts on this site are compatible with that model. Note that although the Educator Vehicle was originally designed to be assembled from the education version of the EV3 kit, I explain on this site how a very similar vehicle can be built with the home version of the EV3 kit.

I am a Windows man, so this site will be oriented towards users of Windows, but users of other platforms should also find the site useful. This site is designed to be compatible with both types of EV3 robot kit: the home edition and the education edition. This site will only discuss what can be achieved with the standard Lego hardware - there will be no discussion of third party hardware. Having said that, it's good to know that it should be possible to use EV3dev and EV3 Python with third-party sensors and motors and even run EV3 Python on other platforms in addition to the EV3, such as Raspberry Pi with either the BrickPi shield or the PiStorms shield. These 'shields' plug into the Raspberry Pi and act as an interface between the Raspberry Pi and Lego EV3 motors and sensors. This means you can use the extra power of the Pi compared to the EV3 and in the case of PiStorms you also get a nice color screen. See HERE.

Now that you understand what this site is about, the next step is for you to install EV3Dev and EV3 Python.
Subpages (2): News Why EV3 Python?