- Standards
- Introduction to robotics and website requirements
- AutoCad 2
- Student Movie Files 4
- Rhino 3d student work
- All about gears
- Animations in 3d Rhino
- Your first robot
- Rubrics and Design Challenge page
- Safety Exam
- Advance Robotics
- Podcast
- Remote Control Tutorial
- HTML Code
- Rattlesnake bot
- Line Follower
- Parking Space
- Robotic Cockroach
- Proportional Control
- Follow the leader
- Platform 9 3/4
- Ramp Bot
- camstudio videos (T.E)
- Digital graphic organizer (T.E.)
- Robotics Safety information
- data log activities
- Engineering Design PowerPoint
- SUMO BOT
- Sumo bot PowerPoint
- Under-carriage inspection
- skype-controlled nxt robot
- Engineering with NI labview : High school robotics activities
- labview training CS2N
Platform 9 3/4
By Jessica Noble
Tufts University Center for Engineering Education and Outreach
This lesson is part of the ROBOT CONTROL ACTIVITY SEQUENCE. For more activities in this sequence, see
the Activity Sequences page on the Tufts CEEO project site.
Introduction
In this activity, we will learn how to build a robot exploring and responding to its environment. The robot is
looking for the movable, or "fake," wall. Have the robot drive until its ultrasonic sensor senses a wall in front
of it. Use a third motor to "knock" on the wall‐‐if the wall moves (i.e. the arm motor can move past a certain
angle), drive forward out of the box. If the arm motor stops, back up, turn around, and try again.
Teaching Standards
We recommend linking your project's content to the nationally recognized Common Core Standards for
literacy in science and math.
Learning Opportunities: In this lab students have the opportunity to understand the following:
How to create a system that controls movement to accomplish a goal
Ultrasonic Sensors
Encoders
Computer programming
Electronics and motors
Dynamics
Teamwork and collaboration
Building and Programming Instructions
Building
Build a LEGO car with two motors for the back wheels (Ports A and B). Make sure that it can turn easily. Add
an ultrasonic sensor to the front of your robot, pointing it forward. Finally, add a motorized arm that can
swing in front of the robot (Port C)‐‐this arm will need to swing about 5 inches in front of the robot and hit a
physical stop when it is backed up.
Programming
This code might be a bit complicated, so before we start, let's map out what we want to do:
a. Make the car drive forward until it sees a wall. Then stop.
b. Swing the arm forward for 2 seconds. If it hits a wall, the motor will stall, and therefore not be able to
rotate as much.
c. Check to see if it hit a solid wall.
d. If it did hit a solid wall, turn around, and try again.
e. If it did not hit a solid wall, drive forward through the fake wall.
Now that we have a basic idea of how the code will work, let's start coding. Use the images here and the
example VI on the lesson’s web page for help.
1. Start with a while loop. Most of your code will go in this loop so it can be repeated until we find the fake
wall. We want the car to drive forward while it does not see a wall. We need another while loop for this. Add
a while loop inside the first, bigger loop. Inside this second, smaller loop, add a Motor Control VI and create a
constant for the Ports input (Ports A and B).
2. Add a Read Sensor VI and select "Read Ultrasonic" from the drop‐down. Create a constant for the Port input
(selecting whichever you plugged the sensor in to‐‐in this example it was plugged into Port 1). We want the
robot to exit this loop when it sees a value less than 7 centimeters in front of it‐‐this means that there is a wall
close by. Add a "Less?" VI (NXT Programming ‐‐> Comparison). Wire the Distance output of the Sonar VI to the
top input of the Less Than VI. Create a constant "7" off the bottom input. Wire this into the loop condition.
3. Finally, we will be adding text to the screen to show us which part of the code we're executing. This way, if
your robot is acting funny, you can easily tell which part of the code has a bug in it. Add a Display Control VI to
this while loop and create a string constant that says "forward" on the Text input.
4. After it sees a wall, we want our LEGO robot to stop. Add a Motor Control VI after the smaller while loop,
and select "Motors off‐‐>Brake" from the drop‐down. Create a constant for the Ports input (Ports A & B) to
stop the car motors. To ensure this happens after the while loop, wire the pink "NXT" output from the Fwd
Motor VI inside the smaller loop to pink “NXT” input of this Brake Motor VI.
5. Now, we have a car stopped in front of a wall. It's time to swing the robot's arm to see if the wall is solid or
not. Add another Motor Control VI, and create a constant for the port (Port C). Depending on how you built
your robot, Forward and Backward may be switched. In our test robot, "Back" swings the arm out, and
"Forward" brings the arm back in. Select the correct direction from the drop‐down. We want the arm to
swing out for 2 seconds to ensure it swings all the way out until it hits something. Add a "Wait for" VI, and
select "Wait for time ‐‐> seconds" from the drop‐down. Finally add a Motor Control VI to brake the robot arm.
Be sure the pink NXT wires of all three of these blocks are wired together in order, and that the first VI is wired
to the "Ports A & B" Brake VI before it. This ensures that the code will execute in the correct order.
6. Add another Display Control VI, and wire the pink "NXT" input node to the wire between the Brake VI for
Ports A&B and the Motor Control VI for Port C.
7. Now that the arm has been swung, we want to see how far out it goes. If it hits something, it won't be able
to extend fully. Add a Read Sensor VI and select "Read Rotation" from the drop‐down. We want to compare
this to the angle the arm will reach if it does not hit a solid wall. If turning the motors forward makes the arm
swing out, add a "Greater?" VI. If your arm motor is backward, like our test robot, add a "Less?" VI. Wire the
"Angle of Rotation" VI into the top input of the comparison function. Create a control for the bottom input of
the comparison. We can test this angle later.
8. Create a Case Structure, and wire the output of the comparison VI into the Case Selector (green question
mark). Also, wire this output into the Loop Condition of your while loop (red stop sign). Now, when we do
successfully find a fake wall, the program will exit the loop when it is done.
9. Inside the "True" case of the case structure, we will put what we want to happen when the robot
successfully finds a fake wall. First, we want to turn the wheel motors on full speed for 2 seconds to drive
through the wall. Add a Motor Control VI, and create constants for the Port and Power inputs. Select "Ports A
& B" for the ports and type "100" for the power input. Add a "Wait for" VI after the Motor Control VI, and wire
the pink NXT wires together. Create a constant for the "Time" input, and type "2" to have the robot go
forward for 2 seconds. Next, add a Display Control VI inside this case, and off the Text input, create a string
constant that reads, "success‐‐drive through wall." Finally, program your robot to play a victory song as it
breaks through the wall by adding a Sound Control VI. Either write your own song using the notes, or use one
of the preloaded songs (the example code uses the "Blue Song").
10. Now change to the “False” case. Inside this case, we will put what we want to happen when the robot finds
a solid wall. First, we want the robot to back up and turn around. To do this, add 2 Motor Control and 2 Wait
for VIs. Using these VIs, back up the motors on ports A and B, and then wait for 1 second. Next, turn the
motor on Port A forward (port B will still be going backward from before), and wait 2 seconds. This should
back the car away from the wall and turn it around. Make sure the pink NXT wires of the VIs are wired
together in the correct order to establish the sequence.
11. Now we need to bring the arm back up. We can do this while it is backing up by not wiring it to anything
within the case structure. First, run the Port C motor in the opposite direction from before (Forward or Back,
depending on your build) at a power of "25." Wait for 2 seconds, and then Brake this motor. Finally, add a
Display Control VI to display "fail‐‐back up" onto the screen.
12. This program should work as it is as long as you start the program with the robot's arm all the way back.
To ensure it always works, despite its starting position, lets add a few VIs in front of the big while loop. First,
we want to run the Port C motor backward for 2 seconds at a power of "25," which should make it hit the stop.
Brake the motor after the 2 seconds. Finally, we want to "zero" the rotation sensor in the motor‐‐add a "Read
sensor" VI and select "Reset Rotation" from the drop‐down. Make sure these four VIs are wired together and
that the last VI is wired to the edge of the while loop to make sure they run before this loop starts.
That's the code for the Platform 9 3/4 activity. Now, let’s create a short program to test the motor rotation so
you can plug this into your front panel. Start with a while loop. Create a constant ("false") for the loop
condition so that your program runs infinitely. Add a Read Sensor VI inside the while loop, and select "Read
Rotation" from the drop‐down. Create an indicator off of the "Angle of Rotation" output. Move the arm all
the way back, and run the program. While the program is running, move the arm, and read the value on the
front panel when the arm has moved past the horizontal position in front of the bot. This is the farthest the
arm should be able to move when there is a solid wall in front of it.
Use this value in your program to compare against the rotation reading of your robot. Load your program onto
your robot, place it in a maze box, and run the program.
By Jessica Noble
Tufts University Center for Engineering Education and Outreach
This lesson is part of the ROBOT CONTROL ACTIVITY SEQUENCE. For more activities in this sequence, see
the Activity Sequences page on the Tufts CEEO project site.
Introduction
In this activity, we will learn how to build a robot exploring and responding to its environment. The robot is
looking for the movable, or "fake," wall. Have the robot drive until its ultrasonic sensor senses a wall in front
of it. Use a third motor to "knock" on the wall‐‐if the wall moves (i.e. the arm motor can move past a certain
angle), drive forward out of the box. If the arm motor stops, back up, turn around, and try again.
Teaching Standards
We recommend linking your project's content to the nationally recognized Common Core Standards for
literacy in science and math.
Learning Opportunities: In this lab students have the opportunity to understand the following:
How to create a system that controls movement to accomplish a goal
Ultrasonic Sensors
Encoders
Computer programming
Electronics and motors
Dynamics
Teamwork and collaboration
Building and Programming Instructions
Building
Build a LEGO car with two motors for the back wheels (Ports A and B). Make sure that it can turn easily. Add
an ultrasonic sensor to the front of your robot, pointing it forward. Finally, add a motorized arm that can
swing in front of the robot (Port C)‐‐this arm will need to swing about 5 inches in front of the robot and hit a
physical stop when it is backed up.
Programming
This code might be a bit complicated, so before we start, let's map out what we want to do:
a. Make the car drive forward until it sees a wall. Then stop.
b. Swing the arm forward for 2 seconds. If it hits a wall, the motor will stall, and therefore not be able to
rotate as much.
c. Check to see if it hit a solid wall.
d. If it did hit a solid wall, turn around, and try again.
e. If it did not hit a solid wall, drive forward through the fake wall.
Now that we have a basic idea of how the code will work, let's start coding. Use the images here and the
example VI on the lesson’s web page for help.
1. Start with a while loop. Most of your code will go in this loop so it can be repeated until we find the fake
wall. We want the car to drive forward while it does not see a wall. We need another while loop for this. Add
a while loop inside the first, bigger loop. Inside this second, smaller loop, add a Motor Control VI and create a
constant for the Ports input (Ports A and B).
2. Add a Read Sensor VI and select "Read Ultrasonic" from the drop‐down. Create a constant for the Port input
(selecting whichever you plugged the sensor in to‐‐in this example it was plugged into Port 1). We want the
robot to exit this loop when it sees a value less than 7 centimeters in front of it‐‐this means that there is a wall
close by. Add a "Less?" VI (NXT Programming ‐‐> Comparison). Wire the Distance output of the Sonar VI to the
top input of the Less Than VI. Create a constant "7" off the bottom input. Wire this into the loop condition.
3. Finally, we will be adding text to the screen to show us which part of the code we're executing. This way, if
your robot is acting funny, you can easily tell which part of the code has a bug in it. Add a Display Control VI to
this while loop and create a string constant that says "forward" on the Text input.
4. After it sees a wall, we want our LEGO robot to stop. Add a Motor Control VI after the smaller while loop,
and select "Motors off‐‐>Brake" from the drop‐down. Create a constant for the Ports input (Ports A & B) to
stop the car motors. To ensure this happens after the while loop, wire the pink "NXT" output from the Fwd
Motor VI inside the smaller loop to pink “NXT” input of this Brake Motor VI.
5. Now, we have a car stopped in front of a wall. It's time to swing the robot's arm to see if the wall is solid or
not. Add another Motor Control VI, and create a constant for the port (Port C). Depending on how you built
your robot, Forward and Backward may be switched. In our test robot, "Back" swings the arm out, and
"Forward" brings the arm back in. Select the correct direction from the drop‐down. We want the arm to
swing out for 2 seconds to ensure it swings all the way out until it hits something. Add a "Wait for" VI, and
select "Wait for time ‐‐> seconds" from the drop‐down. Finally add a Motor Control VI to brake the robot arm.
Be sure the pink NXT wires of all three of these blocks are wired together in order, and that the first VI is wired
to the "Ports A & B" Brake VI before it. This ensures that the code will execute in the correct order.
6. Add another Display Control VI, and wire the pink "NXT" input node to the wire between the Brake VI for
Ports A&B and the Motor Control VI for Port C.
7. Now that the arm has been swung, we want to see how far out it goes. If it hits something, it won't be able
to extend fully. Add a Read Sensor VI and select "Read Rotation" from the drop‐down. We want to compare
this to the angle the arm will reach if it does not hit a solid wall. If turning the motors forward makes the arm
swing out, add a "Greater?" VI. If your arm motor is backward, like our test robot, add a "Less?" VI. Wire the
"Angle of Rotation" VI into the top input of the comparison function. Create a control for the bottom input of
the comparison. We can test this angle later.
8. Create a Case Structure, and wire the output of the comparison VI into the Case Selector (green question
mark). Also, wire this output into the Loop Condition of your while loop (red stop sign). Now, when we do
successfully find a fake wall, the program will exit the loop when it is done.
9. Inside the "True" case of the case structure, we will put what we want to happen when the robot
successfully finds a fake wall. First, we want to turn the wheel motors on full speed for 2 seconds to drive
through the wall. Add a Motor Control VI, and create constants for the Port and Power inputs. Select "Ports A
& B" for the ports and type "100" for the power input. Add a "Wait for" VI after the Motor Control VI, and wire
the pink NXT wires together. Create a constant for the "Time" input, and type "2" to have the robot go
forward for 2 seconds. Next, add a Display Control VI inside this case, and off the Text input, create a string
constant that reads, "success‐‐drive through wall." Finally, program your robot to play a victory song as it
breaks through the wall by adding a Sound Control VI. Either write your own song using the notes, or use one
of the preloaded songs (the example code uses the "Blue Song").
10. Now change to the “False” case. Inside this case, we will put what we want to happen when the robot finds
a solid wall. First, we want the robot to back up and turn around. To do this, add 2 Motor Control and 2 Wait
for VIs. Using these VIs, back up the motors on ports A and B, and then wait for 1 second. Next, turn the
motor on Port A forward (port B will still be going backward from before), and wait 2 seconds. This should
back the car away from the wall and turn it around. Make sure the pink NXT wires of the VIs are wired
together in the correct order to establish the sequence.
11. Now we need to bring the arm back up. We can do this while it is backing up by not wiring it to anything
within the case structure. First, run the Port C motor in the opposite direction from before (Forward or Back,
depending on your build) at a power of "25." Wait for 2 seconds, and then Brake this motor. Finally, add a
Display Control VI to display "fail‐‐back up" onto the screen.
12. This program should work as it is as long as you start the program with the robot's arm all the way back.
To ensure it always works, despite its starting position, lets add a few VIs in front of the big while loop. First,
we want to run the Port C motor backward for 2 seconds at a power of "25," which should make it hit the stop.
Brake the motor after the 2 seconds. Finally, we want to "zero" the rotation sensor in the motor‐‐add a "Read
sensor" VI and select "Reset Rotation" from the drop‐down. Make sure these four VIs are wired together and
that the last VI is wired to the edge of the while loop to make sure they run before this loop starts.
That's the code for the Platform 9 3/4 activity. Now, let’s create a short program to test the motor rotation so
you can plug this into your front panel. Start with a while loop. Create a constant ("false") for the loop
condition so that your program runs infinitely. Add a Read Sensor VI inside the while loop, and select "Read
Rotation" from the drop‐down. Create an indicator off of the "Angle of Rotation" output. Move the arm all
the way back, and run the program. While the program is running, move the arm, and read the value on the
front panel when the arm has moved past the horizontal position in front of the bot. This is the farthest the
arm should be able to move when there is a solid wall in front of it.
Use this value in your program to compare against the rotation reading of your robot. Load your program onto
your robot, place it in a maze box, and run the program.