Programming a Square Path in the LEGO EV3 Programming Environment
One of the most popular ways to program a simple square path for your robot is to use Move Steering programming blocks. Move Steering blocks can be found under the green tab in the LEGO EV3 Programming environment. Note: Learn how to use a loop to create a square path by clicking HERE!
The Move Steering block allows the robot to move by rotating the wheels. Click here to learn how to customize it.
To begin programming a square path, attach a Move Steering block as the starting block.
Next, set your speed to any value between 0 and +100, and set the number of rotations you'd like the wheels to perform. Don't adjust the direction value, as you'll want your robot to drive straight.
Move Steering block with a speed of 58, set to 2 rotations.
Then, add an additional Move Steering block. It's best to ensure that this second block is set to a smaller number of rotations (one rotation often works perfectly), because this will be the block that turns our robot into a different direction! If this block is set to more than one rotation, the robot will rotate too far and will not be able to achieve a tight turn and thus, won't be able to drive in a square. Next, set this new block's direction to either a sharp left turn or a sharp right turn. You can do this by adjusting . See below for an example.
Lastly, you'll need to copy these first two Move Steering blocks and paste them to the end of your code. To do this, highlight the two green blocks by first clicking anywhere in the white space, then drag your mouse cursor over them. The blocks will have a blue outline when you have completed this step successfully.
Once you have successfully highlighted these two blocks, press CTRL+C to copy them, and then CTRL+V on your keyboard to paste them. The result will look like this:
To connect your copied blocks to the code, highlight them and drag them over to touch the pre-existing Move Steering blocks. Your code will then look like this:
Repeat this copy and past process until you have eight Move Steering blocks in a row. This is what your program will look like when it is able to produce a square path for your robot: