EV3 Basic programming

EV3 Basic is Microsoft Small Basic with the EV3 extension. Before you learn how to work with the robotic functions that the extension adds to Small Basic, you should spend some time familiarising yourself with Small Basic programming. Small Basic is a Microsoft product that has been around since 2008 so it's well supported - it has its own website (smallbasic.com) and there are abundant learning materials out there to help you get familiar with the language. Because this is the case, this site does not teach you the basics of textual programming - it is assumed that you will learn the basics elsewhere, such as by working through this PDF guide, before you continue working through this site.

For all the sample programs I propose, I will assume that you are working with a robot similar to the one below. Notice that the wheel motors are attached to motor ports B and C: 

The above model is the official Lego 'driving base' or 'educator vehicle' model that is used in the lessons that accompany the education version of the EV3. Building instructions are available HERE. The above photos include a sound sensor that is not part of the standard driving base, and the gyro is placed in an unconventional (better!) location.

Don't worry if you have the 'home' version of the EV3 set because the education version and the home version of the EV3 set are very similar. The lessons on this site can nearly all be completed with either set, though you may need to make occasional modifications if you have the 'home' version of the EV3 set. For example, if you have the home version, you will need to substitute a different castor wheel at the back of the model and you will need to substitute the infrared sensor for the ultrasonic sensor. You will not be able to include the gyro sensor.

Here are some general tips about writing programs in EV3 Basic:

Important note: all settings dialogs and applications such as 'port view' must be closed on the brick in order to be able to run programs from Small Basic or EV3 Explorer. If a dialog box is open in the brick it will still be possible, however, to use other functions of EV3 Explorer such as compiling programs to the brick.

Recall that EV3 Basic programs can be run in two different modes: PC mode and brick mode.

Compared to PC mode, running programs in brick mode imposes additional rules about writing and saving your programs. Unless you are using Small Basic features such as the graphics window, you should aim to make your programs compatible with both PC mode and brick mode by observing these additional rules, which include:

Here are the lessons!