Key concepts
Computer programming

Have you ever wanted a robot assistant that could do all your household chores? Science fiction has been showing us such robots for decades, but they're still not available! What's taking so long? In this project you will investigate some of the challenges in programming a "robot" to do a simple household task, such as making a sandwich.

Movies and TV are full of robots that can look, feel and act like humans. They can fly, talk, run, jump and do many other things. In the real world, however, robots are much more limited. Humans have gotten very good at building machines or making computer programs that can do one specific thing much better or faster than a human can. For example we have computer programs that can beat humans at games such as chess or TV game shows including Jeopardy. There are robotic arms that can rapidly assemble cars in a factory, much faster and more accurately than people can. You can even buy a robot vacuum cleaner that will automatically clean your floors!

Imagine, however, taking any of those robots and asking it to do a simple household task, such as folding your laundry or cooking dinner. They couldn't do it! They would need to be specifically built and programmed to perform those tasks. In this project you will focus on the programming side of this problem. A computer program is a set of instructions for a computer or robot to follow. Computers are very literal and will follow the instructions exactly, even if you make a mistake when writing the instructions. Things that might seem simple or obvious to a human, such as making a sandwich, will not be obvious at all to a robot. The robot has to be told exactly what to do. In this project you will write a "program" for a person to make a peanut butter and jelly sandwich. You'll ask the person to "think like a robot" and take your instructions very literally. Making a sandwich is so simple—this should be easy, right? You might be surprised!

Note: building a robot that can do all the things a human hand can do—such as picking up objects with wildly different shapes without breaking them—is another entire problem on its own. In this project you will ask a volunteer to act like a robot, so you don't have to worry about building one. See the "More to explore" section for a link to a project on building a robotic hand.


  • Bread
  • Peanut butter
  • Jelly
  • Knife
  • Plate
  • Paper towels
  • Volunteer
  • Pencil and paper
  • Surface that can tolerate a little bit of mess


  • Think about the procedure you follow to make a peanut butter and jelly sandwich. Break it down into a series of steps, one at a time.
  • Write this procedure down as a numbered list (step 1, step 2…). Make sure you include all the steps, even ones you think are obvious.


  • Give your written procedure and other materials to your volunteer. Your volunteer probably already knows how to make a peanut butter and jelly sandwich. Explain that you need them to pretend they have never made a sandwich before. You want them to do it by following your written directions exactly. They need to act like a robot and do whatever the instructions tell them to do—even if that results in making a mistake. They also shouldn't assume any steps that are missing.
  • Watch carefully as your volunteer follows the procedure. Do they make any mistakes? If so, at what step(s) of your program? Write down the step(s) and what problem(s) occurred.
  • Now you need to "debug" your program by fixing the bugs, or errors, in the code. Based on your notes on any mistakes you observed, write a new version of your program and ask your volunteer to try again. Do they make the same mistakes as last time? Are there any new mistakes?
  • Repeat the debugging process until your volunteer successfully makes a normal peanut butter and jelly sandwich. How many attempts did it take?
  • Extra: You could also try doing this project with verbal commands instead of written instructions.
  • Extra: Try this project with other household tasks, such as washing dishes, folding laundry or cleaning your room.

Observations and results
You might have been very surprised to find out that at first, your volunteer failed to follow what you thought were a very simple set of instructions. There are a lot of tiny steps you take when making a sandwich that you might do automatically, without giving them much thought, and you could have forgotten to include these in your program. For example what if your program just said "spread the peanut butter on the bread"? That seems obvious enough to you. However, your volunteer might have done something silly, like used their fingers to spread peanut butter on the bread bag! But remember, your volunteer is a robot that needs very specific instructions. You didn't specify that they should use a knife to spread the peanut butter, or that they needed to take a piece of bread out of the bag first!

There are a lot of other simple mistakes that can happen during this project—such as using the wrong end of the knife, not taking the lid off a jar first, putting the wrong sides of the pieces of bread against each other, etc. Each time you catch a mistake you will have to change your program to correct it and try again. It might take several attempts before you can fully debug your program!

This project might have gotten a little messy if there were a lot of "bugs" in your code! Use damp paper towels to clean up any spilled peanut butter and jelly.

More to explore
Program with Paper: A-Maze Your Friends with a Hand-Written Computer Program, from Scientific American
Build an Artificial Hand, from Scientific American
Study Skills Science: Investigating Memory Mnemonics, from Scientific American
Science Activities for All Ages!, from Science Buddies

This activity brought to you in partnership with Science Buddies

Science Buddies