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 EV3 ・ What is MicroPython
・ Windows 10 PC ・ EV3 body ・ SD card (4GB-32GB) ・ USB cable (EV3 set contents)
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.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.
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.
Connect EV3 and PC with a USB cable.
Install VS Code from here.
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".
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.
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.
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.
This is recommended if you buy EV3 https://afrel-shop.com/shopdetail/000000000380/ct120/page1/recommend/
Python programming with EV3 https://education.lego.com/ja-jp/support/mindstorms-ev3/python-for-ev3
Recommended Posts