This site can be reached via the address ev3python.com.

This site used to be a Google Classic site but Google suppressed all such sites in 2023, requiring me to migrate the site to the newer Google site format. It may be that some aspects of the site were damaged in the migration.

Do you own a Lego EV3 robot? Are you happy programming it with Lego's quirky icon-based system, or are you ready 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!  This site explains how to use EV3dev Python, i.e. Python with the ev3dev extension. I stress that this site is not about how to use MicroPython with the EV3. MicroPython is a 'light' version of Python which runs a bit faster but which is less powerful.

A Udemy course for EV3dev Python!

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

Whether you choose to take the Udemy course or try to get started using only this site, there are some important points to note:

Want to know more about the Udemy course?

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 mind-storms.com. 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 ev3basic.com). 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 ev3dev2.sensor.lego 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 www.ev3dev.org 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. This site is designed to be compatible with both types of EV3 robot kit: the home edition and the education edition.

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 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.