Home Project Ideas Project Guide Ask An Expert Blog Careers Teachers Parents Students

Use the Force! Push & Pull Robots With an Invisible Force

Difficulty
Time Required Average (6-10 days)
Prerequisites You should know how to build a basic car with a LEGO Mindstorms kit, and also be familiar with basic programming in the Mindstorms software (NXT-G or EV3).
Material Availability This project requires a LEGO Mindstorms EV3 or NXT kit, and a computer with the appropriate programming software. See the Materials and Equipment list for details.
Cost Very High (over $150)
Safety No issues.

Abstract

If you have seen any of the "Star Wars" movies, then you probably remember when Jedi knights like Luke Skywalker and Obi-Wan Kenobi used "The Force" to push, pull, and even throw objects — including some helpless battle droids. Have you ever wished you could do that in real life? In this robotics project, you will build and program a LEGO® robot that you can push and pull using an "invisible force" — almost like a real Jedi! We make no promise that you will be taking down the Death Star anytime soon, but this could be a good start.

Objective

Build a LEGO® Mindstorms® robot that you can push and pull by programming it to maintain a preset distance from your hand.

Credits

Ben Finio, Ph.D., Science Buddies

Science Buddies would like to thank the Tufts University Center for Engineering Education and Outreach for providing the LEGO Mindstorms kit and NXT-G software used to develop this project.

  • LEGO® and Mindstorms® are trademarks of the LEGO Group.

Cite This Page

MLA Style

Science Buddies Staff. "Use the Force! Push & Pull Robots With an Invisible Force" Science Buddies. Science Buddies, 10 Jan. 2014. Web. 23 July 2014 <http://www.sciencebuddies.org/science-fair-projects/project_ideas/Robotics_p013.shtml>

APA Style

Science Buddies Staff. (2014, January 10). Use the Force! Push & Pull Robots With an Invisible Force. Retrieved July 23, 2014 from http://www.sciencebuddies.org/science-fair-projects/project_ideas/Robotics_p013.shtml

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.


Last edit date: 2014-01-10

Introduction

If you saw any of the "Star Wars" movies, you probably remember Jedi knights like Luke Skywalker or villains like Darth Vader using "The Force" to lift, crush, and throw objects. Have you ever wished you could use an invisible force to move objects around in the real world? In this project, you will! Well, not just any object. First, you will have to build and program a robot that will respond to an "invisible force" from your hand. The invisible force will let you push and pull the robot back and forth without actually touching it! Watch this video of the demonstration robot we built at Science Buddies:


This introductory video shows the "invisible force" robot we built at Science Buddies and how it behaves using the ultrasonic sensor and a simple program.
Watch this introductory video shows the "invisible force" robot we built at Science Buddies and how it behaves using the ultrasonic sensor and a simple program on YouTube: http://www.youtube.com/watch?feature=player_embedded&amp;v=VZZUlx0lFiQ

This project relies on a few key parts in the LEGO Mindstorms kit. First, you will need to use motors with wheels to build a robot that can move forward and backward. You will also need to use the NXT's ultrasonic sensor. An ultrasonic sensor measures the distance to an object by bouncing sound waves off it. First, the sensor emits a sound wave that travels forward at the speed of sound, away from the sensor. When that sound wave hits an object, part of it bounces back and eventually returns to the sensor. The farther away an object is, the longer it takes sound to bounce back and return. So, by measuring the amount of elapsed time from when the sound is emitted to when it returns, the sensor can determine how far away an object is, as Figure 1 below illustrates.

Robotics science project LEGO NXT ultrasonic sensor function
Figure 1. The farther away an object is from the ultrasonic sensor, the longer sound has to travel to reach the object and then bounce back — which takes more time. This is how the ultrasonic sensor uses sound to measure distance.

Just building a robot with motors and an ultrasonic sensor won't be enough, however. You need to write a computer program to tell the robot what to do. The program you will write for your NXT robot in this project is based on this equation (this equation is called a proportional controller - see the Technical Note at the end of this section for more information):

Equation 1.
  • Motor power in the NXT software is a number between 0 and 100 that tells the motor how fast to spin. At 0 the motor will not move at all, and 100 means it is moving as fast as possible.
  • Constant is a number you pick — it can be anything! The value of the constant will determine how fast your robot reacts when you move your hand.
  • Measured distance is the distance to your hand, measured by the ultrasonic sensor.
  • Desired distance is how far you want the robot to be from your hand.

To help you understand this equation, let's use some examples. Say you pick a value for constant = 2 and desired distance = 30 centimeters (cm). So, your equation is:

Equation 2.

Now, think about what happens in three cases:

  1. Your hand is less than 30 cm from the robot.
  2. Your hand is exactly 30 cm from the robot.
  3. Your hand is more than 30 cm from the robot.

We'll use the first case from above as an example. Let's pretend your hand is 10 cm from the robot. So, you plug 10 cm into Equation 2 for the measured distance:

Equation 3.

The answer is negative 40 — and a negative number means the robot will move backward, away from your hand. The robot "knows" that it is too close — it should be exactly 30 cm away. Can you use Equation 2 to figure out what will happen if your hand is exactly 30 cm from the robot, or more than 30 cm from the robot? Figure 2 below shows what will happen — but make sure you can explain it using Equation 2!

Robotics science project LEGO NXT ultrasonic robot motion diagram
Figure 2. This shows how the robot will behave if the desired distance in Equation 2 is set to 30 cm. If your hand is too close to the robot, it will back up, and if it is too far, the robot will move forward. If your hand is exactly 30 cm from the robot, the motor power will be 0, so it will stop.

Do you understand how the program will work? If not, go back and watch the video again — does it make more sense this time? Once you think you understand how you will be able to push and pull the robot, you are ready to move on to the Procedure section and start building.

Technical Note

Note: Understanding the information in this box is not required to complete the rest of the project — we include it just in case you are curious!

Equation 1 is called a proportional controller, because the control input is proportional to the error. In Equation 1, the control input is the motor power, and the error is the difference between the measured difference and the desired distance. The desired distance can also be referred to as the set point. The constant that multiplies by the error is called the proportional gain. So, you can write a more general equation:

Equation 4.
  • u is the control input
  • Kp is the proportional gain
  • e is the error

This type of equation is used all the time in robotics and engineering. For example, you could also use it to control the angle of one of the motors in your NXT kit — this time the error would be based on your desired angle, and the measured angle from the NXT motor's built-in angle sensor. A more advanced version of the equation can even be used for things like cruise control in a car, or autopilot in an airplane! We don't have room to explain it all here — but if you are curious, you can do an Internet search for "PID control" or "proportional integral derivative control."

Terms and Concepts

  • Motor
  • Ultrasonic sensor
  • Speed of sound
  • Elapsed time
  • Computer program
  • Motor power
  • Constant
  • Measured distance
  • Desired distance
  • Proportional controller (advanced terms — not necessary to do the project)
  • Control input
  • Error
  • Set point
  • Proportional gain
  • Binary

Questions

  • How do ultrasonic sensors work? Can you find examples in nature of animals that use sound to locate things? (Hint: search online for the word "echolocation.")
  • How does Equation 1 work to control the robot's movement? Can you explain each case in Figure 2?
  • How do you think changing the values of the desired distance or the constant in Equation 1 would affect how the robot moves?
  • Can you research other examples in real life where an equation or computer program is used to control something? It doesn't always have to be about robotics - for example, the thermostat in your house controls temperature, so it doesn't get too hot or too cold.

Bibliography

Here are some useful introductions to programming LEGO's official NXT software. Remember that you can also consult the NXT User Guide CD that comes with your NXT kit.

You will need to build a basic robot car for this project. You can certainly design your own car, but if you want help, look at the directions that come with your NXT kit, or search online for designs like LEGO's TriBot:

Materials and Equipment

Substituting LEGO Mindstorms EV3 for NXT:

This project idea was written using the LEGO Mindstorms NXT 2.0 kit. This project can be done with the EV3 kit, because the building system and sensors are very similar between the two kits. However, the programming environment differs between the two kits. To do this project with EV3 you should still follow the general procedure in this project idea, but you may need to consult additional resources for help programming your robot.

For more information about the NXT and EV3 systems, and compatibility between the two, see Comparing EV3 with NXT and LEGO Mindstorms Frequently Asked Questions.

  • LEGO Mindstorms EV3 kit, available from Amazon.com, or a LEGO Mindstorms NXT kit.
  • Tape measure

Disclaimer: Science Buddies occasionally provides information (such as part numbers, supplier names, and supplier weblinks) to assist our users in locating specialty items for individual projects. The information is provided solely as a convenience to our users. We do our best to make sure that part numbers and descriptions are accurate when first listed. However, since part numbers do change as items are obsoleted or improved, please send us an email if you run across any parts that are no longer available. We also do our best to make sure that any listed supplier provides prompt, courteous service. Science Buddies does participate in affiliate programs with Amazon.comsciencebuddies, Carolina Biological, and AquaPhoenix Education. Proceeds from the affiliate programs help support Science Buddies, a 501( c ) 3 public charity. If you have any comments (positive or negative) related to purchases you've made for science fair projects from recommendations on our site, please let us know. Write to us at scibuddy@sciencebuddies.org.

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

Experimental Procedure

Substituting LEGO Mindstorms EV3 for NXT:

This project idea was written using the LEGO Mindstorms NXT 2.0 kit. This project can be done with the EV3 kit, because the building system and sensors are very similar between the two kits. However, the programming environment differs between the two kits. To do this project with EV3 you should still follow the general procedure in this project idea, but you may need to consult additional resources for help programming your robot.

For more information about the NXT and EV3 systems, and compatibility between the two, see Comparing EV3 with NXT and LEGO Mindstorms Frequently Asked Questions.

Build Your Robot

First, you will need to build a basic robot. It should be able to move forward and backward, and have a forward-facing ultrasonic sensor. Feel free to come up with your own design, or use directions from your Mindstorms kit. Directions for the TriBot design are also available online (see Bibliography in the previous section). Figure 3 below shows the robot we built at Science Buddies.

Robotics science project LEGO Mindstorms NXT ultrasonic sensor robot
Figure 3. Science Buddies' simple robot design uses two motors and a forward-facing ultrasonic sensor.

Write Your Program

You have three options to create the program for this project:

  1. If you are an experienced NXT programmer, write your own program based on the information in the introduction (see technical note below).
  2. Figure 4 below shows a screenshot of the program we used. If you are comfortable with basic programming in NXT-G, you can create your own program and use Figure 4 for guidance (see technical note below).
  3. If you are new to NXT programming and need some help getting started, download the program we used: "Use the Force Program (UseTheForce.rbt)".
Robotics science project LEGO Mindstorms NXT proportional controller program
Figure 4. This screenshot shows the program we used for the video in the Introduction. Our default values for the "Desired" and "Constant" blocks were 30 cm and -5, respectively.

Note that, even if you download our program, you might need to change a few things, depending on how you built your robot. Make sure that:

  • You have the correct ports assigned to your ultrasonic sensor and motors. The default values in our program are Port 1 for the ultrasonic sensor and Ports A and C for the motors. You can change the ports by clicking on each block and then selecting the appropriate radio button (1, 2, 3, or 4 for sensors, and A, B, and C for motors) at the bottom of the screen.
  • You have the correct sign (positive or negative) for the block labeled "Constant". This will depend on the orientation of the motors on your robot. The default value in our program is -5 (negative 5). If your motors are positioned like the ones in Figure 3, then this value should remain negative. If your motors are flipped upsidedown relative to the ones in Figure 3 above, then you should make this number positive. You can change this value by clicking on the "Constant" block and then entering a new value at the bottom of the screen.
Technical Note

If you are writing your own program from scratch or using ours as an example, you might be wondering what the "Compare" block is in Figure 4 above (the third block from the right). This block is necessary because the "Motor" blocks only accept a number between 0 and 100 as an input for motor power, not -100 and +100. If you send a negative number to the motor power input, the program will automatically take its absolute value (for example, -50 becomes +50). This is a problem because the motor power calculated by Equation 1 from the Introduction can be either a positive or negative number. Remember:

So, to make the robot go in reverse, you have to change the "direction" input as well. The program works by first calculating the motor power using Equation 1 from the Introduction. Then, it determines if the motor power is positive or negative by comparing it to zero, using the "less than" operation in the "Compare" block. The "Compare" block outputs a binary value (true or false) - true if the motor power is less than zero, and false if the motor power is greater than zero. This binary value is then used as an input to the "Motor" block's direction, which accepts true for forward and false for reverse.

This way of doing things might seem a bit strange — but you need to make sure your robot can go forward and backward!

Download and Test Your Program

First, let's do a simple test to make sure your program is working.

  1. Aim the robot directly at a wall from about a meter away, and start the program. The robot should advance toward the wall and come to a stop.
    1. How quickly did the robot stop? Did it come to a stop smoothly, or jerk back and forth?
    2. Use your tape measure to measure the distance from the front of the ultrasonic sensor where the robot stopped to the wall. How does this distance compare to the desired distance you have set in your program? Note: if your tape measure only has marks for inches and you used centimeters in your program, you will need to convert inches to centimeters.

    If your robot goes the wrong way (backs away from the wall instead of going toward it), then reverse the sign (positive or negative) of the "Constant" block in your program, and try again.

    Now, try using your hand to "push" the robot back and forth.

  2. Put your hand in front of the ultrasonic sensor.
    1. If you pull your hand away from the robot (still being sure to keep it in front of the ultrasonic sensor), does the robot move forward? Do you have to move your hand very slowly, or can the robot keep up if you move your hand quickly?
    2. If you stop your hand, does the robot also come to a stop? Is the motion jerky or smooth?
    3. If you push your hand toward the robot, does the robot back away? Does it stop if you stop moving your hand?

Change the Values in Your Program

Now, find out what happens if you change the values for the "Desired Distance" and "Constant" blocks in your program. It will probably be easier if you change only one number at a time, and use a table to keep track of your results.

Important: as you pick new values for the "Desired Distance" and "Constant" blocks, keep in mind what is physically realistic for the ultrasonic sensor and motors. According to LEGO, the ultrasonic sensor has a range of 0-255 cm — so it doesn't make sense to enter a negative number, or a number greater than 255 cm (note: in practice, we have found the sensor's effective range to be less than that). Remember that the motor power accepts a number from 0 to 100 - so, it probably doesn't make sense to enter a very small number (like .00000001) or a very large number (like a million) for the "Constant." That would result in your robot either not moving at all, or always moving at full speed.

Table 1 below shows just one example of how you could keep track of your data. For each trial, record the value for the desired distance and constant in your program. Then, you can also record things like:

  • The actual distance the robot stops from the wall.
  • The robot's speed as it approaches the wall or follows your hand. You could rate this qualitatively (on a scale like "slow/medium/fast") or use a stopwatch to time how long it takes the robot to come to a complete stop after starting a certain distance from the wall.
  • The quality of the robot's stopping — for example, "smooth/medium/jerky."

If you can think of other ways to rate your robot's performance, feel free to add more columns to your table. What combination of settings gives you the "best" results (movement that is fast, but smooth and not jerky)?

Trial Desired DistanceConstant Actual Distance Speed Stopping
1 30 -1   
2 30 -5    
3 30 -10   
4 20 -1   
5 20 -5   
6 20 -10   
Table 1. A suggested format for keeping track of your data as you change the values.

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.


Variations

  • This project will also work with the NXT's light sensor, since it can measure reflected light from your hand. You will have to change your code, though — not only to use the right sensor block, but because the light intensity value increases as you move your hand closer to the robot — this is the opposite of what happens with the ultrasonic sensor. Can you figure out why?
  • If you increase the value of the "Constant" block in the program too much, your robot might become unstable — it will bounce back and forth when it approaches a wall, without ever actually coming to a complete stop. Can you find out how big the constant has to be before this happens? What happens as you continue to increase the value?

Share your story with Science Buddies!

I did this project I Did This Project! Please log in and let us know how things went.

Ask an Expert

The Ask an Expert Forum is intended to be a place where students can go to find answers to science questions that they have been unable to find using other resources. If you have specific questions about your science fair project or science fair, our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Ask an Expert

Related Links

If you like this project, you might enjoy exploring these related careers:

female robotics engineer adjusting robot

Robotics Engineer

Have you watched "The Transformers" cartoon series or seen the "Transformers" movies? Both shows are about how good and evil robots fight each other and the humans who get in the middle. Many TV shows and movies show robots and humans interacting with each other. While this is, at present, fantasy, in real life robots play a helpful role. Robots do jobs that can be dangerous for humans. For example, some robots defuse landmines in war-stricken countries; others work in harsh environments like the bottom of the ocean and on the planet Mars. At the heart of every robot is a robotics engineer who thinks about what a robot needs to do and works with several engineering disciplines to design and put together the perfect piece of equipment. Read more
Mechanical engineer building prototype

Mechanical Engineer

Mechanical engineers are part of your everyday life, designing the spoon you used to eat your breakfast, your breakfast's packaging, the flip-top cap on your toothpaste tube, the zipper on your jacket, the car, bike, or bus you took to school, the chair you sat in, the door handle you grasped and the hinges it opened on, and the ballpoint pen you used to take your test. Virtually every object that you see around you has passed through the hands of a mechanical engineer. Consequently, their skills are in demand to design millions of different products in almost every type of industry. Read more
electrical engineer aligning laser

Electrical & Electronics Engineer

Just as a potter forms clay, or a steel worker molds molten steel, electrical and electronics engineers gather and shape electricity and use it to make products that transmit power or transmit information. Electrical and electronics engineers may specialize in one of the millions of products that make or use electricity, like cell phones, electric motors, microwaves, medical instruments, airline navigation system, or handheld games. Read more
Computer programmer typing on a keyboard

Computer Programmer

Computers are essential tools in the modern world, handling everything from traffic control, car welding, movie animation, shipping, aircraft design, and social networking to book publishing, business management, music mixing, health care, agriculture, and online shopping. Computer programmers are the people who write the instructions that tell computers what to do. Read more

Looking for more science fun?

Try one of our science activities for quick, anytime science explorations. The perfect thing to liven up a rainy day, school vacation, or moment of boredom.

Find an Activity