Introduction to EV3 / MicroPython

Let's run EV3 with MicroPython

In this article, we aim to run EV3 with MicroPython. It's very easy to do so let's do our best together!

What is EV3What is MicroPython

Things to prepare

・ Windows 10 PC ・ EV3 body ・ SD card (4GB-32GB) ・ USB cable (EV3 set contents)

Environmental setting

1. Download EV3 MicroPython micro SD Card image

Open the following LEGO official website https://education.lego.com/ja-jp/support/mindstorms-ev3/python-for-ev3 Click "Download the EV3 MicroPython micro SD Card image." Wait for a while until the image file is downloaded.

* The environment such as the library is different from "ev3dev" in other articles of our company Afureru.

2. Overwrite the image file on the SD card

I will use Etcher, but any software that can overwrite the image file is OK. Install the software "Etcher" from here. Prepare an SD card. If you have data, please format it. Insert the SD card into your PC and start Etcher. You can overwrite it by selecting the inserted SD card and "Flashing" it.

3. Insert the SD card into EV3

When you have an SD card for MicroPython, remove it from your PC. (Please pull it out safely!) Then plug it into EV3. Let's check if the image file can be overwritten properly here. It's okay if you turn on the EV3 and the screen looks like this.

4. Connect EV3 and PC with USB cable

Connect EV3 and PC with a USB cable.

5. Install Visual Studio Code

Install VS Code from here.

6. Install the extension "EV3 MicroPython"

Install the extension for MicroPython in VS Code. Press "Ctrl + Shift + X" to bring up the extension screen. Search for "EV3 MicroPython" in the search bar. Install "LEGO MINDSTORMS EV3 MicroPython".

7. Creating a project

You should see the following icon on the left side of VS Code. Click on it to open the tab. Create a new project, enter the project name, and press Enter. You will be asked where to save the project, so choose a suitable location.

8. Connect EV3 and EV3 MicroPython

Open the File tab on the left side of VS Code and open "EV3DEV DEVICE BROWSER". ↓ This is the file tab. Click Click here to connect to a device and select ev3dev (Ethernet). If a green circle is attached like this, the connection is successful! If there is no problem, you are ready for programming. Thank you for the time being.

Try to move

Actually, a program called "main.py" was created when the project was created. Open the EV3 MicroPython tab and open "main.py". Something is written in various ways.

main.py



#!/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()

This is a program that makes a buzzer sound. You can run the program by pressing F5 Let's press F5. (Let's not get an error!)

How about that? Did the buzzer sound? If you can ring it safely, the introduction is over! Thank you for your hard work.

Product introduction

This is recommended if you buy EV3 https://afrel-shop.com/shopdetail/000000000380/ct120/page1/recommend/

Reference site

Python programming with EV3 https://education.lego.com/ja-jp/support/mindstorms-ev3/python-for-ev3

Recommended Posts

Introduction to EV3 / MicroPython
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to Tkinter 1: Introduction
Introduction to PyQt
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
Introduction to discord.py
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to Python language
Introduction to TensorFlow-Image Recognition
Introduction to OpenCV (python)-(2)
Introduction to PyQt4 Part 1
Introduction to Dependency Injection
Introduction to Private Chainer
Introduction to machine learning
AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4
Introduction to electronic paper modules
A quick introduction to pytest-mock
Introduction to dictionary lookup algorithm
[Learning memorandum] Introduction to vim
Introduction to PyTorch (1) Automatic differentiation
opencv-python Introduction to image processing
Introduction to Python Django (2) Win
Kubernetes Scheduler Introduction to Homebrew
An introduction to machine learning
[Introduction to cx_Oracle] Overview of cx_Oracle
[Introduction to pytorch-lightning] First Lit ♬
Introduction to Anomaly Detection 1 Basics
Introduction to RDB with sqlalchemy Ⅰ
[Introduction to Systre] Fibonacci Retracement ♬
Introduction to Nonlinear Optimization (I)
Introduction to serial communication [Python]
AOJ Introduction to Programming Topic # 5, Topic # 6
Introduction to Deep Learning ~ Learning Rules ~
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
[Introduction to cx_Oracle] (8th) cx_Oracle 8.0 release
Introduction to discord.py (3) Using voice
An introduction to Bayesian optimization
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
Super introduction to machine learning
Introduction to Ansible Part ③'Inventory'
Series: Introduction to cx_Oracle Contents
[Introduction] How to use open3d
Introduction to Python For, While
Introduction to Deep Learning ~ Backpropagation ~
Introduction to Ansible Part ④'Variable'
Introduction to vi command (memorandum)
[Introduction to Udemy Python 3 + Application] 58. Lambda
[Introduction to Udemy Python 3 + Application] 31. Comments
Introduction to machine learning Note writing
To add a C module to MicroPython ...
Introduction to Python Numerical Library NumPy
Practice! !! Introduction to Python (Type Hints)