EV3 basics course. Motors control and program from the brick (part3)

The LEGO EV3 Mindstorms brick can be programmed from the brick itself. The motors can be moved forward/backward and even simple programs could be implemented without even touching the EV3-G software at the computer

  • #130
  • 29 Sep 2015
  • 8:22

EasyBot build with LEGO Mindstorms EV3

Building instructions for the EasyBot LEGO Mindstorms robot using in many of our courses and tutorials. This EasyBot has two motors and two front wheels. The third wheel is...well, check it out, see how the third wheel is built. 


After we are finished with the robot, now is time to try to program this robot. For this we'll need two cables, and there are different kind of cables with different lengths in the set We must connect the cable to the motor and to the ports of the brick. These here are the ports of the brick. We have 4 ports here and 4 ports here. These are port A, port B, port C, port D and these ports are 1, 2, 3, 4 So you can use the ports at the upper side of the brick to connect the motors. So you connect the motors only to the ports on the upper side of the brick. These are the output ports because the brick is controlling the motors and these are the output ports. The other 4 ports are the input ports and you attach different sensors here. You connect different sensors and these are the input ports you get some feedback from the sensors, when you connect to this ports. So let's connect our robot. Our motor to port A and then the other motor to port D.

And we have our robot. I'll turn it on.

We'll have to wait a few seconds.

Now the brick has turned on and as you can see there is a nice menu here and you can use the buttons to move through the menu and select different options. For example, I will now move and it is possible to program the whole brick from the brick itself So it's possible to use this buttons to move the motors. Let's see how it goes. I'll select motor control. Motor contol

Select And then we are moving motor A and motor D This means that we are now controlling the motors that are connected to port A and port D and as you can see we have one of the motors connected to port D and one of the motors connected do port A Now. We can use the buttons here to control the motors. For example, if we press this button here, the upper button, and motor A moves and if we press the lower motor D moves. So in this way we can control the motors This is useful only for you to see you've connected the motors and just do a few little test with the motors it's not real programming just controlling the motors. But, nevertheless it's convenient sometimes to make sure you have battery, you have the cable well connected and just to do a few experiments. We can then exit this menu with the Back button, this here is the back button on the brick The next thing that I want to show is that you can program this robot, so you can control the motors on this robot from the brick, but you can also program the robot from the brick itself, which is quite interesting, again, it's only for small experiments for more complex program, actually for any real program you'll need to use the computer but it's nice to have this on the brick so that you can do small experiments when you are not certain of something and you need something very fast Now when you go to this menu and you can again

you can select Brick program and we can see these two blocks, the first block is Play and the next is Repeat What does this mean, Repeat one means that we'll repeat the program only once so the program will run only once. And if we now select this block

we can change the value to, let's say 2 This means that the whole program will repeat twice What is the program we move with the buttons on the line that's connecting the two blocks we press the upper button and then we select a block that we want to be executed and I would like to move a motor and this here is the block for moving only one motor Select and this we'll be motor D, so I'll move motor D which is this one because it's connected on port D So I'll move motor D and I'll move it forward and while moving forward this will repeat two times. Now if I run the program I go to the Run block and I press Run

and as you can see nothing happens

and you kind of might start wondering what's wrong with the program and this is probably the first thing you need to learn that we'll always have to control the time and the duration for which these blocks are working. For example, when we select that we want to have motor D to move forward we didn't say for how long, for one second, for two seconds, until something happens, for how long and that's why motor D actually starts but it ends and this happens in milliseconds so we don't see it. Let's go and add one more block here, it's Wait block

and I would like to wait for 2 seconds so the program is

Play, then we start motor D, then we wait for two seconds, and at the end we'll repeat the program one more time. Let's now run the program

As you can see motor D is moving Again, it's about for 4 seconds. One, Two, Three, Four

So this is one very fast and easy way to program the robot without even starting the computer. For different tasks on using the brick for programming check out the link below we've provided again three tasks so that you can learn more about programming from the brick