Required Knowledge and Parts:
A remote-controlled robot is very useful. It can go places that humans cannot go. An operator can sit anywhere and remote the robot thousands of miles away to complete tasks. Boston Dynamics' robot dog is very famous in Singapore during the Covid-19 circuit break period.
The robot EV3D4 robot is a simple remote-controlled robot created using Lego Mindstorms EV3. You can be assemble it with the following guide from Vassilis Chryssanthakopulos and Philippe “Philo” Hurbain.
Troubleshoot: As the connector wires given in the kit are not long enough, flip the EV3 Brick upside-down as shown in picture below:
The guide and videos are created by Terence Kon, the Sitizen Ambassador.
In order to utilize and program the robot in Python, MicroPython is needed. MicroPython is Python for Microcontrollers, In this case, MicroPython for EV3 is needed. The MicroPython image and guide for EV3 can be seen in the following link
What you need
Internet connection is needed to update the software as well as to install the dependencies and Python code. A Bluetooth connection to the Computer is used to remotely control the robot from a distance.
Please look at this guide on how to connect to the EV3 Brick via Bluetooth. (You may ignore the Windows 10 warning in the guide, as an Internet Connection was possible on Windows 10)
Connect to EV3 terminal using Secure Shell (SSH)
Using a SSH client such as PuTTY to connect to the EV3 Brick to install additional software and run the program. In our case, PuTTY is used as our SSH client. PuTTY is an open source SSH and telnet client. PuTTY can be downloaded here, Download PuTTY. The steps to connect PuTTY to the EV3 Brick can be found here, SSH connection to EV3 Brick
ev3devfor the “host name”. Then click the Open button to connect
robot) and the password (
maker) if you haven’t changed it yet and then you should be logged in.
Preparing the MicroSD
The Python program for the EV3D4 Robot can be downloaded from here
Using Visual Studio for EV3
Ensure that you have LEGO® MINDSTORMS® EV3 MICROPYTHON on your Visual Studio
You should see ‘EV3DEV DEVICE BROWSER’ on the lower left corner of the Visual Studio Interface:
Next, click on ‘Click here to connect to a device’.
You should see ‘ev3dev’ show up:
Troubleshooting: If this does not show up, please check your SSH connection. Refer back to the Bluetooth guide. If Bluetooth connection is not possible, then connect the EV3 brick to the computer using the cable provided. Do note if this option is used, the movement range will be limited by the cable length.
If connection is successful, you should see the ev3dev device in Visual Studio Code:
Next, open the project file previously downloaded:
At the top left hand corner of the Visual Studio Interface, click on File>Open Folder>Downloads>EV3D4-ssh_control-master
After the file is selected, click open
You should see 3 files in the Visual Studio Code Interface as follows
Click on the ev3dev dropdown arrow
Next, click on ‘send workspace to device’:
You should see the files get downloaded onto the EV3 brick:
Note: Any further change made to the python file has to be re-downloaded onto the EV3 brick before it will have effect
Going back to the SSH Interface:
Change directory (cd) of the SSH to the workfile:
i.e., type ‘cd EV3D4-ssh_control-master’ into the interface:
Press Enter if you have not done so
Next, run conbot.py using the python3 method:
i.e., type ‘python3 conbot.py’
Press enter if you have not done so.
Once you see LOG, you can now control the robot
|import subprocess||Allows user to spawn new processes, connect to their input/output/error pipes, and obtain their return code.|
A process that can be run only on UNIX devices (i.e. the EV3 brick)Provides an interface to the POSIX (i.e. SSH connection) calls for I/O (Input/Output) control
|import tty||Give ability to define functions on the EV3 brick. Requires termios import|
|import sys||Allows ability to give commands remotely to the EV3 brick via the SSH connection|
|From ev3dev.ev3 import*||Import the functions native to the EV3 device|
conbot.py python class variables
Layman terms: modifying this will affect the rest of the code in the python file
|motor_left||Defines output to the motor connected to port C. It is the left motor of the robot|
|motor_right||Defines output to the motor connected to port B. It is the right motor of the robot|
|motor_a||Defines output to the motor connect to port A. It is the motor that controls the robot’s head|
conbot.py python instance variables
Layman terms: modifying this will only affect one function
|getch()||Listens to the user input from the SSH connection and passes it to the EV3 brick|
Turns the robot’s head to the left(You may wish to modify its name to something more understandable. Try to also adjust the speed to a lower rotation to avoid tangling the wires of the head)
Turns the robot’s head to the right(You may wish to modify its name to something more understandable. Try to also adjust the speed to a lower rotation to avoid tangling the wires of the head)
|marchaimp()||Play the Imperial March from Star Wars. You may upload your own file to change songs|
|fire()||Simulates a fire on the robot, making the head turn very fast. It is recommended to remove the wires from the head before coding this function onto the commands|
|forward()||Moves the robot forward.|
|back()||Moves the robot backward.|
|left()||Rotates the robot to the left|
|right()||Rotates the robot to the right|
|stop()||Stops all motors|
At line 69, the actual instructions given to the robot starts.
getch() is always running, so that the Robot is always listening to user input. User input is thereafter defined by variable k.
For the rest of the functions, the keys are defined by a character.
if k == ‘w’:
This means that if the w key is pressed on the computer, the robot will move backwards forever.
You may wish to input the other defined functions into the control functions by writing the command. Note that python is sensitive to indentation, as can be seen from the example. The back() function is tied to pressing the ‘w’ key.
Troubleshoot: If you have quit the command interface by pressing q, you can re-start the program by typing 'python3 conbot.py'