Edit & Run programs

Having followed the instructions in the videos on the installation page, you have established a network connection but have not yet started using SSH (Secure SHell) to manage the communication between the EV3 and the computer. The video below shows how to use the SSH program MobaXTerm. If you prefer to use PuTTY on your Windows PC or if you are using a MacOSX or Linux computer then you should refer to THIS PAGE.

The workflow that I recommend is to first use your SSH program (PuTTY or MobaXTerm, for example) to create an empty Python program file on the brick, open and edit that on the computer and save the modified file back to the brick. This is in my opinion the best way of working because it avoids the confusion of having two copies of the same file, one on the brick and one on the computer, and perhaps not being sure which copy you are working on or whether the two copies are in sync. So here is my 35 minutes video to help you through the next step: creating, editing, and running EV3 Python programs:

The video shows how to easily create a new Python file on the brick using MobaXTerm: just click the 'New File' button, name the new file, being sure to end the filename with .py, and click OK. It's also possible to use the command line of your SSH program to create a new Python file on the brick by using the '>' character. For example, to create an empty Python file with the name myscript.py, type > myscript.py . You should see this:

Notice that you are returned to the prompt with no indication that a file was created. You can check that the file exists by using the “ls” command if you wish. Alternatively, if you are using MobaXTerm, click the 'Refresh Folder' button to see your new file in the panel that shows the list of files in the current folder. Warning: this method will overwrite an existing file with that name without warning you!

Another command that works similarly to using the right arrow (>) to create an empty text file is the “touch” command. Type “touch” followed by a filename. For example type touch myscript.py to create an empty Python file with the name myscript.py. This will NOT overwrite an existing file with that name and is therefore the preferred method (thanks for the tip, Cort in Singapore!)

You would like it to be possible to run your program either from the command line of your SSH program or from within the Brickman interface on the brick. To make it possible to run the Python script within Brickman, you need to do two things:

Once you have made the Python script executable, an asterisk (*) will be displayed after the file name in Brickman's file browser, so you will be able to see which .py files are executable and which are not.

Run your Python script from the command line

python3 <filename> is used to launch a Python file in the current folder within Python3. For example, to launch a Python file called drive.py, use python3 drive.py . Most programs will terminate by themselves but some will continue to run until you force them to stop by typing Ctrl+C at the command line.

Run your Python script from within Brickman

To run a program from within Brickman, just open the file manager from the main menu, select your .py file and press the enter (middle) button. This will launch your Python file provided it includes the correct 'shebang' and that the file has been made executable as explained higher up this page, otherwise you will get an error message. Most programs will terminate by themselves but some will continue to run until you force them to stop. If the program was started within Brickman you can long-press the 'back' button to end any program.

Reset the brick

If you ever need to reset the brick, use the shortcut 'back' + 'enter'.