# How to move specific distance in mm in Mindstorms EV3-G (build a block) ProPreview

Have you even tried to move the robot not in rotations or degrees or seconds, but in metres. In this episode I am building a new block that could be used to move the robot a specific number of millimetres (mm). You could directly download and use it in your programs.

• #38
• 02 Sep 2013
• 6:25

The block would give you a chance to do measurements on the FIRST LEGO League field and to positions yourself faster by specifying the distance in mm. This, of course, could be done offline, calculated on a piece of paper, but it is much more convenient to leave the robot to do it.

Route, designed by factor_e from the Noun Project

### Distance Move Project

- a program containing the Distance Move block. Download and use the block directly in your programs.

### English

As a result of this video we will develop a new block that's called DistanceMove, where we can specify the distance in milimeters, that we would like our robot to move for example 200 milimeters and the power. And our robot will move exactly 200 milimeters. You can of course find this program in the material section, where you can directly download it and use it in your robots.

First I need a new move block and I will configure it to use rotations the number of rotations we want and the motors are connected on ports A and B. Let's check how it works.

Next we should check the radius of the tires, that this robot use and as you can see the radius is 28 mm so we will use this value. In our program what we would like to achieve is to somehow specify the distance, that we would like to move in mm, for example 200. Then we will do a small mathematical calculation where we will divide this number 200 to the number of milimeters in the circumference of the tire. So its 176 and we will use the result of this mathematical block to pass to the move block and it goes like this. We add this variable where we write the numerical value of 200 then we take another variable block, where we read the value of the distance, so we should select read and then we pass this value of 200 to the mathematical block. We choose the operation divide so we divide the number of 200 to 176, which will give us the number of rotation, that this robot should do in order to move 200 mm forward. Than we take the result of the operation, right here and we pass the result to the move block. Okay, let's see how it works.

Оur next step is to move this whole logic in a new block that will be called DistanceMove, where we can specify the distance and the power of the motors and we will see the whole robot move the specified distance. We select all the blocks, we open tools, then myBlock builder we would like to call this new MyBlock DistanceMove and we will choose an icon for this DistanceMove for example this one and we would like to have two parameters for this block the first parameter is called Distance in mm and it will be a number with default value of 0. It will have an icon for example, this one. The secon parameter is the power of the motors we have the second parameter, called power. It's again number with default value of 75 and let's choose an icon for power. The icon for power is for example this one. Okay and we are finished. Now we have our distancemove block, where we will remove this variable distance and these are our input parameters for the block. The first input parameter is the number of milimeters we would like to move, we will pass this to the mathematical block. The second parameter is the power of the motors, we will pass this to both motors and we will add this program right here. As a result we have new block it is a myblock it receives two parameters the distance in milimeters and the power and we can use this distancemove block in our program. For example I will move this here just to show you, it is located right here in myblocks, I'll delete it. I will take new distancemove and I would like to see my robot move for example a 150 milimeters with the power of 75. Let's download and run it

Let's do a number of tests here, as we have the distancemove, we will move forward for a 150 milimiters and then a new block to move backward with the power of -75 for a 100 milimeters and then we will again move forward

for 50 milimeters. Let's see how this program works.