Your First Lego Vehicle

We will build a 3-wheeled robot vehicle with two motorized wheels, and an extra wheel that can pivot, called a "caster". It is possible to build a robot with 4 or 6 wheels, or with treads, like a tank, but the 3-wheeled robot is the easiest to program, so that's what we'll use. A robot with a caster generally runs best on very smooth, flat surfaces, so that the caster can glide easily. For rougher surfaces, 4 wheels or treads may work better. Follow the steps below to build the robot vehicle.

Step 1: Attaching Wheels to the Motors

     Step 1 - Motors

     Step 1 - Motors

     Step 1 - Motors

Step 2: Attaching Angled Beams to the Motors

     Step 2 - Motors

     Step 2 - Motors

     Step 2 - Motors

Step 3: Adding Wheels and Motors to the Bot

     Step 3 - Wheels and Motors

     Step 3 - Wheels and Motors

     Step 3 - Wheels and Motors

     Step 3 - Wheels and Motors

Step 4: The Attachment Bar

     Step 4 - Attachment Bar

     Step 4 - Attachment Bar

     Step 4 - Attachment Bar

Step 5: The Caster

     Step 5 - Caster

     Step 5 - Caster

     Step 5 - Caster

     Step 5 - Caster

Step 5: The Wiring - Use two medium length (35 cm) wires to connect the motors to ports B and C on the NXT. Make sure that the motor on each side is connected to the port on that side.

     Step 6 - Wiring


The Vehicle Program

Move Block vs. Motor Block

To make the motors turn, we can either use the Move Block or the Motor Block.

Move Block
(The Move Block)
Motor Block
(The Motor Block)

There are several differences between the two blocks, but the biggest is that the Move block can control one, two, or three motors at one time, while the Motor block can only control one motor at a time. The Motor block allows you to control the motor in more detail, but for driving, you usually want to have at least two motors running two wheels at the same time. This is why we'll stick with the Move block to drive our robot.

The Move Block

     Move Block Code

The Move block controls one, two or three motors simultaneously.

     Move Block Code

Look at the settings for the move block. Let's figure out what each one does:


Moving in a Straight Line

Move Block Code

Let's figure out how far the car will go when we input certain data to the Move Block. Create a simple program in NXT-G, consisting of a single Move Block. Save it in your folder on the S drive with the name "Move Test".

Use your Move Block program to answer some of the questions below. Write your answers on a separate piece of paper, and you may need a calculator:

  1. What happens to the vehicle if the motor on the left side runs faster than the motor on the right side (assume both motors are turning forwards)?

  2. What is the circumference (distance around) of a tire on your robot (in centimeters)? __________ centimeters

  3. How far do you think the car will go (in centimeters) when the wheel turns one time? __________ centimeters

  4. Try it. How far did it go? __________ centimeters

  5. How far do you think the car will go (in centimeters) when the wheel turns 5 times? __________ centimeters

  6. Try it 3 times and compare your results:
    How far did it go?

    __________ centimeters __________ centimeters __________ centimeters

  7. How accurate do you think the Move block is? _______________

  8. If you want the robot to travel 20 centimeters, how many turns should the wheel make? __________ turns.
    Try it. Did it work? __________

  9. How many degrees correspond to one rotation of the wheel? __________ degrees

  10. How far will the car go if the wheels turn 720 degrees? __________ centimeters

  11. Try it. How far did the car go for at 720 degree rotation? __________ centimeters


Turning

The robot will always turn when its wheels spin at different rates. In most cases, it's hard to predict where it will go when both wheels are turning at different rates, so we'll focus on two kinds of turns that we can predict: Pivoting in Place, and Turning with One Motor. You can control which kind of turn you make with the steering setting. The following steering values give you the following different kinds of turns:

Steering Value Steering Results
  100   Pivot in place to the right
    50   Turn to the right using one motor
      0   Go straight
   -50   Turn to the left using one motor
 -100   Pivot in place to the left

Pivoting in Place

If you turn both motorized wheels in opposite directions at the same power (speed), the vehicle will pivot around a point halfway between the two powered wheels, as shown in the picture below. The wheels travel around a circle whose diameter is the length of the axle.

     Pivoting in Place

The tricky part is to figure out how many rotations the wheels need to complete a single turn. Let's do the calculation, and then compare it to real life by programming our vehicle. Write your answers on a separate piece of paper, and you will probably need a calculator:

  1. What is the distance across the circle the car makes when it turns? __________ centimeters

  2. The circumference (distance around) the turning circle is about 3.14 x diameter = __________ centimeters

  3. How many rotations does the tire have to make to travel the circumference of the circle?

    The formula for the answer is:

    (Circumference of turning circle) ÷ (circumference of tire) = __________ rotations

Download and run your program. Did it work?

Check with your instructor if you're not sure of the answer.


Turning with One Motor

If you give power to only one motorized wheel, while holding the other one still, the vehicle will pivot around the unpowered wheel, as shown in the picture below.

     Pivoting in Place

Let's do a calculation like we did above. Remember, in this case, the diameter of the circle the car makes is two times the length of the axle. Write your answers on a separate piece of paper, and you may need a calculator:

  1. What is the diameter (distance across) the circle the car makes when it turns? __________ centimeters

  2. The circumference (distance around) the turning circle is about 3.14 x diameter = __________ centimeters

  3. How many rotations does the tire have to make to travel the circumference of the circle?

    The formula for the answer is:

    (Circumference of turning circle) ÷ (circumference of tire) = __________ rotations

Download and run your program. Did it work?

Check with your instructor if you're not sure of the answer.


Commenting your Program

Now that you know how to go straight and turn, you can combine a series of move blocks in a row to make your robot follow a certain path. When you have a lot of Move blocks in a row that look similar, it is a good idea to place comments near each move block so that you know what it's doing. That way if you have to make any changes, it's easy to find the right place.

You can add comments to your program using the comment tool Comment Icon at the top of the NXT window. An example of a commented Move Block program is below:

     Code Comments

Challenges for You

(1) Big Circle: Can you write a program to make the Robot travel in a 30 centimeter square, using only 2 move blocks?

(2) Lego Maze: Your instructor has set up a maze lined by blocks. Can you program your robot to navigate the maze without knocking over any Lego blocks?

(Note: Before you start programming, measure the distances in the maze to predict where you want your robot to go. You will probably have to adjust your program afterwards, but you will have a good starting point.)

(3) Lego Garage: Your instructor has set up a "parking garage" made of blocks. Can you drive your vehicle from the starting point to park in the garage, without knocking over any of the blocks?

(see your instructors for help with the answers)