Starting your STEM Journey: Running your First Program with the Virtual Robotics Toolkit

They say that you must walk before you can run, and much like taking your first steps, practice makes perfect. This is an age-old sentiment that’s true for running your first program with the Virtual Robotics Toolkit as well!

Complex programs are difficult to master right away, they may take hours of practice. That’s why this guide is intended to give you a starting point as you begin your coding journey. Without further ado, let’s teach you how to program your first simple program: a square path.

Programming a Square Path

When programming a square path, you may want to avoid the hassle of adding a long line of blocks, primarily because it will save time! This is where loops come in handy. Rather than your program looking like this…

….you could use a loop to simplify it and make your program look like this!

Let’s first look at some of the basics.

Basics of Programming

One of the basic programming blocks is the Move Steering block, which allows you to adjust the number of rotations, seconds, or degrees the robot’s wheels will turn for. It can be found in the Action Programming tab.

Action Programming tab
Move Steering tab

To begin programming a square path, attach a Move Steering block as the starting block. Before continuing to build your line of code, we suggest taking a quick read through the Move Steering Block article on LEGO’s EV3 Programming Guide.

Next, set the speed of this block 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 for the first leg of its journey.

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.

Next, set this new block’s direction to either a sharp left turn or a sharp right turn. You can do this by adjusting the directional value, pictured below:

Your program should now look like this:

Drag the highlighted blocks into the loop you have already placed. It should look like this:

This program, by default, will repeat indefinitely. If you would like the program to repeat for a certain number of repetitions, seconds, etc., adjust the value in this column:

Connecting to the Virtual Brick

Before your robot can run the program you’ve just created, it must be connected to the LEGO EV3 Programming environment! This can be done in two simple steps.

1. Turn on the virtual brick by pressing the center button

2. Enable WIFI

Connect your virtual brick to WIFI by clicking the box underneath the WIFI icon. Doing this will allow your robot to run your program.

Running your Program

There are three ways to download and run your program in the simulation environment.

1. Click “Download and Run”

Once you have created a program and are ready to try it out, click the gray play button in the bottom right corner of the LEGO EV3 Programming environment. Clicking this button will automatically download and run the program in the simulated environment, it will just take a couple of seconds to work!

2. Using the EV3 Virtual Brick

If you prefer a more realistic programming experience and want to use the EV3 Virtual Brick to run your program, this option may be for you. First, click the downwards arrow icon in the bottom right corner of the LEGO EV3 Programming environment. Clicking this button will download your program to the virtual brick.

Next, navigate to the Virtual Robotics Toolkit window and click the centre button on the Virtual Brick. Note: If it’s not visible, pull up the EV3 Virtual Brick by clicking the EV3 button in Simple Mode (if you are in Advanced Mode, press F12 to change to Simple Mode).

EV3 Button

3. Clicking the Play Button in the EV3 Programming Environment

The third way you can put your newly made code into action is by pressing the green play button in the EV3 Programming Environment.

Simply connect the virtual brick to the EV3 Programming Environment, then click the button (pictured) to play the program!

Play Button

More Resources

Facebook – @cogmation
Twitter – @cogmation
Instagram – @virtualroboticstoolkit
YouTube – Virtual Robotics Toolkit
LinkedIn – Cogmation Robotics

Leave a Reply

Your email address will not be published. Required fields are marked *