Lego Robotics

Robolab 2.54 vs. NXT Robolab 2.9

When in doubt, use the Help context! This will show you what the inputs and outputs for every icon should be.


  1. Write a program that will make your car go forward for 1 sec. Remember to stop your motors after 1 sec. Use modifiers to set the motor speed to 3.

  2. Change your program so that the car will go backward for 1.5 sec. Use the new NXT green light to give your program a name.

  3. Write a different program to make your car move forward exactly 12 inches. (Hint: use the  NXT wait for rotation, circumference of the wheel is 8 in.) Use the motor power 100 icon to set the power level to 50. Use modifiers to set the ports for the motors and the blank stop sign.

  4. Change your program so that you can set the distance in inches instead of degrees of rotation. You will need to define a variable and set it to the number of inches you want the robot to go. You need a function that describes how many rotations the motor needs to turn to go 1 inch. The result of the calculation is called rotations and is put in the red container. The value in the red container is used to set the number of rotations for the motor.

  5. Time for some driving. Using the wait for rotation again, figure out how far to rotate to make the car turn right. Then add to the program to make the car drive in a square(forward, right turn, forward, right turn, etc.)

  6. Go back to the instruction book and add the touch sensor. Write a program to go forward until the touch sensor is pressed and then go backward. You can use wait for time or wait for rotation to determine how far backward to go.

  7. Let’s follow a line. Go back to the instruction book and add the light sensor. You want it to be ¼ inch or less from the surface. Use a sensor fork to break the program flow into two paths one goes straight if the sensor is on the line, and one turns when the sensor gets off the line. With just one sensor, the robot must follow the edge of a wide line.

  8. Robot ears: Go back to the instruction book and add the sound sensor. Now write a program to start the robot going in a straight line when you clap and then stop when you clap again. You may need to adjust the level that it takes for the robot to hear a clap to a higher value if you are in a noisy room. You want to add a wait before detecting the stop clap or you might start and stop on the same clap. The computer and sensor are very fast.

  9. Robot eyes:  Back to the book again. Add the ultrasonic sensor.  The ultrasonic sensor measures distance in centimeters.  Write a program that makes the car back up if something gets closer than 25 cm. Back up to a distance of 50 cm then stop.

  10. Write a program that makes the car go forward until something is closer than 25 cm then turn right to avoid object.

  11. Write a program to make the car find the closest  object and then go toward that object. Stop at 5 cm from object.



ANSWERS: Question1, Question2, Question3, Question4, Question5, Question6, Question7, Question8, Question9, Question10, Question11