Things You'll Need
Instructions
Start the LEGO Mindstorms software on your computer. Open a new program, so you have a blank canvas with an empty sequence beam.
Decide what you want your robot to do, based on its design and how you put it together. For example, you could have a robot walk or drive up to a target, then punch or shoot that target. You need to think about this task sequentially, like a robot would: break it into single, actionable steps. Walk, stop at target, shoot or punch.
Drag a Move block to the sequence beam to add it. You will find the icon in the "Block" palette along the left-hand side of the screen, with a picture of gears on it. Click the block once to bring up the configuration panel at the bottom. Select which motors you want to activate, for how long, and in which direction.
Click the Wait block, an hourglass icon, to bring up the various input options. You can have the robot react to sound, color, light, distance, or simply do something when a certain time period has elapsed. Click the block appropriate to your robot's sensors--the distance sensor, for example, and drag it to the sequence beam.
Click the block to bring up the configuration panel again. Change the settings on this sensor, such as which port it's connected to, and how far you want the robot to stop.
Drag a Move block to the sequence beam, and configure the robot to stop. This tells the robot that, once it's close to the target, it needs to stop. If you forget this block, the robot will charge into the wall.
Place another Move block on the beam to activate the punching or shooting motor on your robot. Drag and drop it to the beam, and choose the correct motor on the configuration panel, depending on which one is connected to the robot.
Make the robot play a tone each time it shoots by bringing a Sound block to the beam, dropping it in front of your second Move block. Configure the NXT brick to play a tone instead of a sound file.
Make the robot shoot or punch several times, by bringing a While block onto the sequence beam. This is pictured as two arrows pointing at each other in a circle. Use the configuration panel to tell the robot how many times to complete a certain action.
Drag the Sound block and the shooting motor's Move block inside the looped While block. This completes your first program: the robot will walk up to a target, and punch or shoot at it the number of times you've commanded it to.