How to make a LEGO EV3 motor rotate forever? Pro Preview

Every once in a while you need to make your motor rotate indefinetely. In such cases we use the On setting of the move block followed by a wait block and then finally another move block set to Off. But what happens if we want to make the motor rotate forever not waiting for any sensor? If we just put a move block and set it to On, it will not work. So how can we achieve that? Learn bellow the most common techniques to make a motor rotate forever.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1249
  • 02 May 2019

Before we get into how to make it work, we firstly should explain why it does not work when you put a single move block set to On. A program with a single move block will work if the program does not end. However, as there is just one block in the program and that block does not "wait" but let the program "continue" to the next block and there are no next blocks, the program just finishes. As a result all of the motors are turned off. This is what happens always when the program exits. So we just need to figure out a way to make sure the program will never exit.

The first two ways are the most common. Moreover it is easier to understand and "read" the programs if you use one of the first two options. We advise you to use them unless your program demands another approach.

  1. Unlimited loop
    1.  Put a move block set to On inside of a loop set to Unlimited. This way we will constantly turn on the motor and it will rotate forever.content picture
    2. Put a move block set to On and after it put a loop block set to Unlimited. It is almost the same idea as the previous one, but here we start the motor and then the loop does not allow the program to end as it loops forever. This results in the motor rotating forever!content picture.
  2. Impossible or unmeetable conditions
    1. After the move block set to On, we can add another move block. The second move block needs to drive a motor that is not connected to the brick and set to rotations or degrees. As the motor can not be rotated, the block will never finish and as a result the program will never exit. This will not work with seconds as this does not need to have the motor rotating it just needs to wait for the set amount of time to pass.content picture
    2. Another approach is to add a wait block for a sensor that is not connected. This will also work if we use different sensor from the one connected to the given port. As an example, if we have a touch sensor connected to port 1 and add a wait block that waits for the ultrasonic sensor to detect a distance equal to 50 cm. It is important to choose a value that does not exist in the right sensor. So in the example of the touch sensor 255 will be a bad value to use as the brick will read the pressed touch sensor as 255 cm distance measured by the ultrasonic sensor.content picture
    3. Same as the previous, but a more special case is to use wait with rotation sensor for the motor we are using, but with a value that it will never reach. So if we are moving the motor forward and we wait for it to reach -1 degrees.content picture
  3. The last option is handy if you want to perform some check every once in a while. We put a move block, set to some number of degrees, inside a loop block set to Unlimited. Note that you need to set the Break option to False, so that the movement of the robot is smooth.content picture

All of the mentioned approaches work with both EV3 Large and Medium motors and all of the move blocks.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Level D2. "Seafaring". Robotics with LEGO
  • 24
  • 2:49
  • 107
Image for Lesson 3 - Storm Simulation
  • 3
  • 5
  • 12
  • 3d_rotation 1
Image for Robotics with LEGO - Level 2.5 - Maritime Journey
  • 42
  • 3:52
  • 133
Image for Lesson 7 - Aircraft Carrier
  • 6
  • 4
  • 11
  • 3d_rotation 1