Hobbies And Interests
Home  >> Toys >> Construction Toys

How to Program LEGO Robots

The LEGO Mindstorms kit contains a powerful computer and a programming language you can use to bring your robots and creations to life. Learning to program the Mindstorms software is not too hard, but the challenge may be learning to think like a robot before translating what you want to do into a program. After that, you just have to download the instructions to your robot and test the program out.

Things You'll Need

  • LEGO Mindstorms kit
  • LEGO Mindstorms software
  • USB cable or Bluetooth chip
Show More

Instructions

    • 1

      Start the LEGO Mindstorms software on your computer. Open a new program, so you have a blank canvas with an empty sequence beam.

    • 2

      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.

    • 3

      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.

    • 4

      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.

    • 5

      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.

    • 6

      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.

    • 7

      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.

    • 8

      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.

    • 9

      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.

    • 10

      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.


https://www.htfbw.com © Hobbies And Interests