This is a course on programming the Lego EV3 robot (either the home or education version) with EV3 Python. This course does not teach the basics of Python, so you should be familiar with basic Python before taking this course.
Hello, I'm Nigel Ward. I've taught computer science and physics in many of the world's top international schools but recently I've been focused on helping people learn how to program the world's most popular pedagogical robot, the Lego EV3, with the world's most taught textual programming language, Python.
So, should you take this course?
This is a course on programming the Lego EV3 robot (either the home or education version) with EV3 Python. This course does not teach the basics of Python, so you should be familiar with basic Python before taking this course.
Hello, I'm Nigel Ward. I've taught computer science and physics in many of the world's top international schools but recently I've been focused on helping people learn how to program the world's most popular pedagogical robot, the Lego EV3, with the world's most taught textual programming language, Python.
So, should you take this course?
You should not take this course if you don't have access to a Lego EV3 robot, of course.
You should not take this course if you want to make lots of cool-looking Lego robots because this course is about programming, not about building many different robots. Using variations on a standard design, the official Lego Education Vehicle is also a deliberate choice to make it possible for this course to be used in schools, where teachers don't have the time or pedagogical justification to have kids making many different models.
You should not take this course if you don't already have some knowledge of the basics of the Python programming language. This course will NOT teach you the basics of Python, and learning the basics of Python by learning how to program robots would make no sense because the special commands used to control robots are not basic Python commands. There are many ways to learn the basics of Python, including some good courses right here on Udemy.
You should not take this course if you are looking for some version of EV3 Python other than the one based on the ev3dev operating system and Python version 3. In particular, this course is not about the EV3 Python variant known as EV3 MicroPython.
You SHOULD consider taking this course if you like working with the Lego EV3 robot but want to program it with a more powerful, more standard programming language than the standard Lego one, sometimes called EV3-G. In fact the standard Lego programming language isn't really a language at all – it's a set of icons that you configure and connect together – this is very different to the textual programming languages used by professional programmers. In this course you will learn how to program the EV3 with the Python programming language, the most taught textual programming language in the world. This course won't teach you the basics of Python, but it will give you plenty of practice in working with basic Python concepts, and at the same time you will be learning about robots, which is really important given that robots and artificial intelligence are going to have a huge impact on human society in the coming decades. Billions of jobs are going to be partially or completely automated, and you should do all you can to prepare for the coming changes and to boost your chances of getting a job in one of the few fields that are likely to grow. Anything that deepens your knowledge of Python and robots increases your chances of getting a well-paid job. Python programmers are generally very well paid – in the US, for example, the average salary of Python programmers is well over 100 thousand dollars per year, equivalent to more than 4 million dollars over a whole career. With those kind of figures in mind, ask yourself whether it's reasonable to worry about the cost of taking this course, and don't forget also that Udemy has a money-back guarantee if you're not satisfied.
Working with robots, even a robot as modest as the Lego EV3, also increases your chances of getting a job working with robots, of course, and is one job area that is likely to grow quickly while others are automated out of existence in the coming years. Even if you don't work with robots, understanding how they work will make you feel more comfortable in a world where they will strongly impact our lives.
Wait a moment, did I just describe the EV3 robot as 'modest'? It's actually quite expensive compared to many other small robots out there. OK, so you're paying for Lego quality, reliability and modularity, but you're also paying a lot for something else: the possibility of programming your robot with many different programming languages. The EV3 can do that because at its heart is the so-called 'intelligent brick' a proper little Linux computer. When you buy an EV3 kit with more than 600 pieces there is one piece that costs more than all the other pieces combined – it's the intelligent brick. So if you spend all that money to have the possibility of programming in multiple languages and then only ever use the quirky Lego software then I'm afraid, my friend, that you may have wasted quite a lot of money.
Speaking of buying an EV3 kit, there are two types of kit out there: the retail (home) version, and the education version. Although the kits are rather different, this course is designed to be compatible with both types of kit. Due to differences between the two kits there are a couple of exercises that can only be completed with a specific kit, but the vast majority of the exercises can be completed with either kit.
As I said, the EV3 intelligent brick can be programmed in many different languages, but the fact that you're reading this indicates that you've already figured out that Python is the best choice among the many textual programming languages out there. It's become the most-taught textual programming languages in the world thanks to its combination of power, simple syntax and conciseness. In fact many experts now consider Python to be the world's most popular programming language.
This course is cheap compared to the cost of an EV3 and compared to the boost that Python and robotic skills can give to your career prospects. Could you get the information in this course elsewhere? Some of it, no doubt, but this course is built around a new and very simple way of programming the EV3 with Python, so you won't find much out there to compete with this course. This course is based on programming with a free, open source, multi platform code editor called Microsoft Visual Studio Code, or simply VS Code. VS Code is compatible with Windows, MacOS and Linux. Recently an extension was released for VS Code that makes it very easy to write and run Python scripts for the EV3. How easy? As easy as 1, 2, 3. Once everything is set up, all you need to do is:
Write your Python script
Save it
Run it by pressing the F5 key (or by running it directly on the EV3, of course)
To summarize, here are some of the things you can expect to learn on this course:
Not only will you learn how to use your EV3 with a different and much more serious programming language but you will learn about many new functions are not available in the standard Lego software, such as speech synthesis and vastly improved handling of variables and text.
You'll get familiar with Visual Studio Code, a great multi-platform code editor used by many professional coders
You'll learn how to install Visual Studio Code on your computer and how to install extensions
How to usefully modify the VS Code settings
How to flash an alternate EV3 operating system (EV3dev) to an SD card
How to download all the official Lego sounds and images to the SD card so that they can be used by your EV3 Python scripts.
How to write code to interact with EV3 motors, sensors, buttons, display and speaker.
How to assemble the official Educator Vehicle (education set) or a similar vehicle (home set).
How to assemble a drawbot/writerbot.
Even if you don't plan to become a professional coder, learning to program will sharpen your thinking skills – coding does not forgive sloppy thinking.
You will learn (the hard way. ) that when robots operate outside carefully controlled factory settings and in the messiness of the real world their behavior tends to be somewhat approximate and unpredictable, unlike the perfectly predictable, perfectly accurate behaviors of programs that only output to a screen.
Learning about robots is vital, of course, in a world where robots and artificial intelligence are set to have a huge impact on human society over the coming decades. Maybe you'll never be a professional robot programmer but knowing how robots are programmed may make you feel more comfortable about the prospect of sharing your world with them.
Perhaps most important of all, you'll get lots of practice studying and modifying Python scripts, and thus deepening your knowledge of Python. A good knowledge of Python is extremely valuable in the workplace – remember how I said that in the US Python coders make more than 100 thousand dollars a year, on average?
So join now and boost your valuable Python skills while at the same time having find with your Lego EV3 robot.
There are about 20 videos altogether, with a total duration of about 5 hours. High quality subtitles are available for every video. The essentials of EV3 Python programming are explained in parts 1 and 2 (two hours) and parts 3 and 4 mainly give practice and examples. As such, parts 3 and 4 are optional.
In addition to the videos, this course includes:
A ZIP file with most of the Python scripts that are discussed during the course.
A PDF document (about 100 pages) which is essentially the script of the various videos.
Build instructions for the home version of the Education Vehicle and a link to build instructions for the education version of the Education Vehicle.
Build instructions for a bumper attachment.
Build instructions for a drawing and writing robot that is the subject of parts 3 and 4 of this course.
Table of Contents
Introduction (3 minutes)
Part 1: Setting up
1A (9 minutes) Set up the EV3
1B (5 minutes) Connect the EV3 to the computer
1C (23 minutes) Install VS Code and the two needed extensions, configure, and connect to EV3
Part 2: The Components
2A (24 minutes) Motors
2B (30 minutes) The Intelligent Brick (display, buttons, LEDs and speaker)
2C (19 minutes) Sensors
Part 3: Putting the pieces together (43 minutes)
3A (3 minutes) Collide, back up, turn and continue
3B (2 minutes) Line follower
3C (7 minutes) Wall follower
3D (9 minutes) Steer with light
3E (2 minutes) Follow an object
3F (3 minutes) Follow a beacon (only for home model)
3G (5 minutes) Program with colors
3H (9 minutes) Self-parking
3I (3 minutes) Beware of steep slopes (only for education model
Part 4: Make a drawbot and a writerbot
4A Drawbot part 1 (38 minutes, with the option of skipping the final 15 minutes which is a mathematical derivation)
4B Drawbot part 2 (22 minutes)
4C Writerbot part 1 (33 minutes) Write a script that can write characters that do not contain arcs.
4D Writerbot part 2 (22 minutes) Modify the script so that it can also write characters that contain arcs
In this short introductory video I summarize the ideas that were presented in the trailer video. This course teaches shows you how to get started programming the Lego EV3 robot using EV3dev Python. It does not teach you the basics of Python which you should have acquired elsewhere before starting this course.
First you need to download an image file containing EV3 Python and the ev3dev operating system, a modified version of the Linux Debian Stretch operating system. Then you need to 'flash' that image to an SD card with a utility such as Etcher which is free to download. When you put the card in the EV3 and boot up the EV3 you will meet the Brickman interface that allows you to establish a connection between the EV3 and the computer, run Python files and do much more. Running EV3 Python on the SD card has the huge advantage that the firmware on the brick is not modified in any way so any time you want to return to the traditional icon-based EV3 programming environment all you have to do is turn off the EV3, remove the card and reboot.
This course is based on the use of a free, multi-platform code editor called Microsoft Visual Studio Code (VS Code) which is relatively easy to use but nevertheless popular with professional coders for all but the most complex tasks. VS Code is free to download for Windows, MacOS and Linux. This course shows you how to install the two needed extensions (Python and the EV3 Device Browser extension) and configure VS Code so that EV3 Python files can be run simply by pressing the F5 key.
The twenty or so videos that make up the bulk of this course are in four parts:
In part 1, we set up the EV3 and the computer and establish a connection between them.
In part 2, we learn the essential code that allows us to interact with the EV3 motors, sensors, display, buttons, LEDs and speaker.
In part 3, we develop some slightly more complex EV3 Python scripts, each making use of more than one of the just-mentioned components.
In part 4, we develop some significantly more complex scripts as we make a drawing/writing robot, for which building plans are provided. Since you will have learnt the essential commands for interacting with the EV3 by the end of part 2, you could consider the last two parts as optional but I encourage you to work through them because they will deepen your Python skills and because… you paid for them!
The resources attached to this lesson include:
a PDF document of about 100 pages which is essentially the script of all the videos
a ZIP file with most of the EV3 Python scripts used in this course and the code that needs to be copied into VS Code's user settings file
a troubleshooting document in PDF format
This lecture is the table of contents of the roughly twenty videos, both as an overview and in detail. The PDF resource is the same but also contains listings of the scripts that are included in the ZIP file resource that accompanies this course and information on where to find the build instructions for the education vehicle base, a bumper attachment for that model, and the drawbot/writerbot. In every case build instructions for both the home (retail) version and the education version of the EV3 are included.
In this video I first indicate where to find build instructions for the 'Education Vehicle' model (also called the Robot Educator or Driving Base). This is an official Lego model that is the basis for the most of the exercises included with the education version of the EV3 software. Instructions for building that model with the education version of the EV3 can be found here:
· education.lego.com/en-us/support/mindstorms-ev3/building-instructions#robot
· robotsquare.com/2013/10/01/education-ev3-45544-instruction/
Instructions for building a similar model with the home (retail) version of the EV3 kit are attached to this lecture as a downloadable resource. The home and education versions differ significantly in the size of the main wheels and the rear wheel mechanism. Also, the selection of sensors that is included with each version of the EV3 kit is not the same, and this means that a small number of exercises can be attempted with only one version of the Educator Vehicle.
Once you have built the Education Vehicle model, this video will guide you through the steps of setting up the EV3 robot for use with EV3 Python:
1. Obtain a suitable microSD memory card.
2. Download the latest Linux Debian Stretch ev3dev image.
3. Download and install Etcher, a free utility that will allow you to flash the ev3dev image to the microSD card.
4. Use Etcher to flash the image to the card.
5. Insert the card into the SD slot on the EV3, turn on the EV3 and explore the Brickman interface
In this video you will learn how to establish a connection between the EV3 and the computer, which can be via USB, Bluetooth, WiFi or Ethernet.
In this video you'll learn how to install VS Code and the two needed extensions, how to configure VS Code, and how to establish a connection between VS Code and the EV3. Here are the main steps:
1. Download and install Microsoft Visual Studio Code (VS Code). This is a free multi-platform code editor, compatible with Windows, Mac OS and Linux.
2. Start VS Code and install the two extensions that we need.
3. Configure VS Code. Note that at one point you will copy code and paste from a file that is included in the introductory lecture as a downloadable resource.
4. Write and run some non-EV3 Python scripts.
5. Connect VS Code to your EV3.
6. Open the starter project folder in VS Code and run the starter script.
In this lecture you'll learn the basic EV3 Python commands for controlling the standard EV3 large and medium motors. Not only does EV3 Python have commands for controlling individual motors but also for pairs of motors, typically used to propel a mobile robot such as the Education Vehicle. These commands are equivalent to the Move Steering and Move Tank commands of the traditional icon-based programming system, so if you are familiar with those then you will have little difficulty learning the EV3 Python equivalents. Sample scripts are included on the ZIP file that accompanies the introductory lesson as a downloadable resource.
In this section you'll learn how to use EV3 Python to interact with the brick's LEDs, screen, sound and buttons. EV3 Python has much more powerful text handling and graphics capabilities than the icon-based system, so learning to use EV3 Python to control the display is something of a challenge. EV3 Python also has speech synthesis, an extremely useful feature that is not available in the traditional icon-based system. Not only that, but's very easy to use! It can be very helpful for prompting users to take certain actions while a script is running, especially since the EV3 display is small and dim and thus does a poor job at this. You will also learn how to display a BMP image on the display or play a WAV sound, where to download suitable sound and image files and how to download them to the brick.
This lesson explains how to use all the sensors that come with either the home or education version of the EV3 kit. Don't forget that the ultrasonic and gyro sensors are included only with the education version and the infrared sensor (and the infrared remote control/beacon) is included only with the home kit. These sensors are available for purchase as optional extras. As far as possible, I propose similar scripts for the ultrasonic and infrared sensors, both of which are capable of measuring the proximity of objects (the ultrasonic sensor is capable of far greater accuracy).
Note that EV3 Python is compatible not only with all the EV3 sensors but also with the older NXT sensors except that the NXT light sensor cannot be used to detect colors. EV3 Python is also compatible with many non-Lego sensors but that is not discussed here for this course only covers what can be achieved with standard EV3 kit.
This is the first of a number of lectures that present slightly more complex scripts that make use of multiple components. In this exercise, for example, we interact with the touch sensor and the motors to control the robot which advances until it hits an obstacle, then back up while turning, then continues on its way.
Using the color sensor to make the robot follow one edge of a black line is a classic challenge.
In this exercise you will learn how to make the robot follow a straight wall a a roughly constant distance, making use of either the ultrasonic sensor or the infrared sensor, according to which version of the EV3 kit you own. We improve the first script by introducing the concept of proportionality. We also think about how to deal with corners on the wall and even to solving mazes, though these challenges are not addressed in full.
It's a fun challenge to try to steer the robot using nothing more than the brightness of a flashlight that is held at varying distances above the robot. Hold the flash light close to the robot so that it detects a bright light and the robot will turn right. Hold the flashlight far away and it will turn left. Easy to understand, code and build, but surprisingly different to control!
In this lesson we also learn how to calibrate the sensor. We calibrate the color sensor so that the robot knows what it the dimmest and brightest light that it should expect.
In this lesson you will learn how to make the robot follow an object at a respectful distance, using either the ultrasonic or infrared sensor. This reminds me of a duckling following its mum!
The infrared sensor and beacon are included in the home version of the EV3 kit but not the education version so this exercise can only be attempted by owners of the home kit. It is similar to the previous exercise but takes advantage of the infrared sensor's ability to detect a rough bearing (direction) of the beacon to cause the robot to turn while it follows the beacon.
It's nice to be able to give the robot instructions after the program has been launched, and one way of doing that is to show a sequence of colors to the color sensor. We'll associate each color with a certain movement that we want the robot to execute. We'll store the colors in a list (called an 'array' in the traditional icon-based programming system) so this exercise will give us practice working with lists.
We hear a lot about self-driving robotic cars and no doubt they will outnumber human-driven cars within a couple of decades. We can expect that as soon as it becomes clear that self-driving cars are much safer than human-driven cars it will be made illegal for humans to drive any more on public roads. Anyway, to be comfortable with technology we need to be familiar with it and understand it, so let's see whether we can make a simple self-parking vehicle. We'll set our vehicle moving in a straight line parallel to a 'line of cars' (actually just a straight wall) and our script will try to detect a break in the line of cars that is long enough and wide enough for our vehicle to be able to park, and then our vehicle will reverse neatly into the space, or so we hope.
We'll use a sideways-pointing ultrasound or infrared sensor to detect spaces in the 'line of cars'. The infrared sensor is much less precise than the ultrasonic sensor for measuring distances so we can't expect that to work so well.
The gyro sensor is included in the education version of the EV3 kit but not the home version so this exercise can only be attempted by owners of the education kit. The gyro monitor is used to monitor the steepness of the terrain over which the robot is moving. If the terrain becomes dangerously steep then the robot will play an alert sound and back up a little.
It would be neat to be able to make drawings with the EV3! Making drawings gives a tangible product, gives lots of potential for writing different programs and lots of scope for creativity. Good results have already been achieved by making the drawing with an arm that is attached to a fixed base since that stops the robot from wandering away from its intended location. But that severely limits the drawing to be a small size. Making a drawing with a robot that is free to move removes the size limit on drawings but also make it difficult to get a satisfactory result due to the robot's tendency to wander away from its intended position. We could try to use a sensor of some kind to limit the accumulation of errors in the robot's motions but that would complicate the code and we have to remember that the home and education kits do not contain the same set of sensors. So let's try to make a drawbot that does not use sensors - perhaps with careful coding we can get satisfactory results for drawings that are not too complex?
The code for this project is significantly more sophisticated than the code that we have seen previously - this project is designed to give a sense of what a real coding project might feel like.
Building plans for the drawbot are attached to this lesson for both the home and education kits. The design considerations for the two models are rather different and this leads to the two models having very different appearances.
To complete this project you will need to obtain a white board marker with a diameter of not more than 1.8 cm. The marker should preferably have a 'bullet tip' rather than a 'chisel tip'. A pencil or ball-point pen would not be suitable. You also need to obtain a couple of small elastic bands.
The last 15 minutes of this video is a mathematical derivation which you can skip if you wish. If you choose to work through the derivation then it makes more sense to do that using the PDF document than the video so that you can work at your own pace.
This is the second and final video in the drawbot project.
In this project we will make a writing robot or ‘writerbot’ using the same model that we used as a drawbot. Even if we limit ourselves to capital letters and digits (0-9) only, that's 36 characters, so this is quite an ambitious project! It could also lead to a very long script so in part 1 we will limit ourselves to writing characters that consist only of straight lines. So that errors do not accumulate too much, we should not try to write strings of more than about 5 characters. You can change the target string in the code to make the writerbot write whatever short word you want, except that in part 1 you are limited to characters made up of only straight lines (in the video I write the word 'ALIKE').
This is the second and final video in the writerbot project. We extend the writerbot code to enable it to also write characters that contain arcs.
This video also includes a conclusion in which we review the many skills you have learnt in this course!
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.