Several Ways to Design Your Own MoveTank Method by Using LEGO EV3 Micro Python

As my previous post mentioned, LEGO released version 1.0 of EV3 MicroPython in April of 2019. Compared to EV3Dev Python, the EV3 Micro Python is more compact. Some blocks in the original LEGO blocks could not find the corresponding methods in Micro Python. For example, MoveTank and MoveSteer blocks.

This is an disadvantage of EV3 MicroPython, but on the other hand, we could utilize this chance to learn how to realize the functions of MoveTank by ourselves. In this post, I will introduce three methods and then compare their characteristics.

Method 1: run and turn, but cannot be interrupted

In the following LEGO blocks, the vehicle drives in an alternative straight/turn sequence, over and over, until the program is stopped by the Backspace button on the LEGO brick. It uses two MoveTank blocks and one Loop block to realize this effect.

Let’s see how to implement the above effect by using Micro Python. Firstly, there is a default import section at the head of

Then, in the following method, I use motor.run_angle() method. Please pay attention to the last argument – “wait” of this method. If it is set to True, the program will wait until the motor has traveled precisely the requested angle. That means, the program will stop here to wait for the method to finish. If it is set to False, the program will continue executing down the code, so the final effect will be that the robot iterates between moving straight and turning at a super short interval (just think about how fast the computer can execute the code) without reaching the expected angles at all.

In order to realize MoveTank effect, the program needs a bit tricks. It first calls left_motor.run_angle() method with the “wait” argument set to False, so that the program will continue executing forward. Then right_motor. run_angle method will be called with “wait” argument set to True. In this combination, both motors will run at specified speed, but when the right motor rotates to the specified angle of 720, the program finishes executing right_motor.run_angle() and then moves down to the following code. That is just the effect of MoveTank!

The advantage of this method is that it is simple and short, but it could not be interrupted when executing right_motor.run_angle() in which the “wait” segment is True. If you press brick button or touch sensor but the program is still waiting for right_motor.run_angle() to execute, the program is of no response to your action.

In the next section, let’s find another way to make an improvement.

Method 2: run and turn, stop when brick button is pressed

In this scenario, we rearrange blocks to add a parallel code line, as shown below. In this code line, the program will continue monitoring the brick button pressing action. Once any brick button is pressed, it calls Interrupt Loop block to stop the loop called “running loop” and then the program will execute Stop Block, which leads to the completion of the whole program. That’s it!

For the Micro Python code, I first call method. This method only sets the speed for the motor and the program will continue executing forward. I use while conditional loop to check left motor’s angle to see if it turns the expected angle. If the angle has not reached 720 degrees, the while loop will repeat executing. If any brick button is pressed, the loop will break and calls “sys.exit()” to stop the whole program.

This feature of this method is that it could be interrupted any time by brick button pressing, which is advantageous to method 1. It is just a bit more complicated than the first method.

Method 3: Use DriveBase class

The third method is to use DriveBase class. Its implementation is a bit different from the above two ways. DriveBase.drive_time() method needs forward speed and steering speed to drive the robot. It could do this because the user has given the wheel diameter and axle track value when creating DriveBase object. The drive_time method just calculates within it how much the rotary speed should be for each motor to turn. However, if the user does not give an accurate wheel diameter or axle track value, the turning and straight forward effect would compromise.

The feature of this method is that it is super short and looks simple. The disadvantage is just like the first method. It could not be interrupted unless the user presses the brick button.

That is all for the three implementation approaches of MoveTank. My favorite one is the second method because it gives more flexibility in interacting with other buttons or sensors. What is your opinion? Give me some comment below.

And finally, don’t forget to enjoy the coding and have fun!

Note: All the analysis articles are copyright products of Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.