Pin Me

Mindstorms NXT In The Classroom, Session Four: Giving Your Robots A Brain

written by: Sean Fears • edited by: Laurie Patsalides • updated: 9/11/2012

Even the most advanced machine is nothing more than a paperweight without the programming to back it up. This lesson introduces the students to the programming basics necessary for getting their robots moving and interacting autonomously with their environment.

  • slide 1 of 1

    The mere mention of computer programming is enough to strike fear in the hearts of many adults, but never fear; LEGO has taken remarkable strides towards making the experience as pleasurable, accessible, and straightforward as possible while still leaving the room for more advanced users to write remarkably sophisticated programs.

    Even before they get started on the computer, help them to define the task that they will be trying to accomplish. Once they’re working on the computers, they’re less likely to pay attention to the finer details of planning! Emphasize the need to consider what the sensors, motors, and TECHNIC parts are capable of- creating a robot that can hug the walls of a room or maze is possible, while making a robot that can run on two legs is not, or, at least, not with stock parts!

    To get started, start the LEGO Mindstorms NXT software, then select either “Start New Program” or “Open Recent Program”. Have the students select the first option, then decide on a name for their team. To facilitate finding their files again, a very important concern when programming, have them use a consistent format such as “Team name-program number”. Once they have done this, they will see a gridded screen with a Mindstorms icon and a highlighted box labeled “Start”. To the left is a palette that allows you to access different categories of commands: Move, Play, Sound, Display, Wait, Loop, and Switch are the available categories, in order. To get started programming, all you have to do is find the programming block you want, click on it, and drag it into the program.

    For the purposes of this exercise, we’re going to restrict our work to the Move and Sound blocks. Have the students select one, then drag it into the program and drop it. As soon as they do this, the program will link it to nearby blocks in order to establish a sequence for program execution. Looking at the bottom of the screen, they will notice different variables that they can change: in the case of the move block (the one with the gears on it), the controls allow you to alter the direction of the robot (making it turn), move duration and the time span associated with it, the power setting, and whether the motor actively stops or coasts after the move is finished. The sound block settings allow you to adjust the volume, play a sound file or tone, repeat, or wait until the completion of the previous move to start this block.

    The initial goal of all teams is to program their robot to move forwards to a point, pivot 180 degrees, play a sound, return to its starting point, pivot 180 degrees, the play another sound to signal completion. When everyone has finished, discuss the exercise as a group.