This is part of my 15 minute focus series. Children learn about the idea of computer programs that give a machine instructions for what to do. (This is intended as a follow-up to What Is a Robot?)
Objective: children can give examples of how robots’ programming work (e.g. the robot goes straight till it runs into something, then it turns)
Supplies
Some way to demonstrate if/then/else programming:
- a Roomba / robot vacuum cleaner, or
- a toy that has a sensor where if it is about to run into something (like this crab robot), or about to fall off a “cliff” (like this other crab robot) it will turn and go in another direction, or
- a video of a Roomba in action, such as this one or this one from 1:49 – 2:22)
Optional but really cool: a programmable robot, such as Code and Go Robot Mouse, or mTiny. Or I assume a Bee-Bot and Robot Bear work in a similar way.)
If / Then / Else
Remind kids that last week, we learned that robots have three things: sensors that give them information about the world around them (like our senses do), processors / computer programs that take the information from their sensors and decide what to do (like our brains do), and actuators that do actions (like our bodies do.) But robots are nowhere near as smart as we are! They have really limited senses, really limited decision making, and really limited options for what to do.
Tell them that for some robots, their job requires that they just go in a straight line till they can’t for some reason, then they turn and go in another straight line till they have to turn. The program is called: if / then / else. IF you can go in a straight line, THEN do, ELSE turn. Use the vacuum, toy, or video of the vacuum to demonstrate this. (It’s fun if you narrate it dramatically: “Can I go straight? I think I can, I think I can. Oh No! It’s a wall, gotta turn…”) Some of these robots have sensors that tell them they’re about to fall over a cliff (like off the side of the table) but some don’t so we have to catch them before they fall!
Do a demo with a robot, or watch a video.
Then ask them: can the robot do anything else? Can it climb stairs? No? Can it climb walls? No? Can it jump? And so on. Can it decide not to turn? Nope. No free will – it only follows its program.
If I shout at the robot to tell it to do something else, will that work? Nope – it only follows its program.
Game: Program Says
Play a game like Simon Says, except it’s Program Says. If you say “Progam Says Touch Your Nose” they should touch their nose. If you just say “Touch Your Nose”, the robot doesn’t understand, so they don’t do it. (Note: Simon Says is hard for many four year olds – their impulse control and listening skills may not be quite there yet.)
Or play an if/then/else game, where they walk straight till them almost run into something, then turn, and so on. Or, they turn until you say stop, or jump until a bell rings, or dance till the music stops, or whatever. Or: “if my hand is up in the air, put your hand up. If I put my hand down, you clap.”
If you have a small group of kids, and a rug with squares marked on it, like we do, you can play a really specific game related to your robot toy. Say things like “OK, I’m starting a new program. You’ll go forward one, then backwards two. OK, I press the green button that says run program.” (They all go forward one, backwards two.) Work up to three or four step programs.
Programming a Robot
If you have a toy robot they can program, do so. For example:
With the Code and Go Robot Mouse, you show them how it works. I narrate it the same way on each demo. “I press the yellow button to say ‘I’m starting a new program.’ Then I press other buttons: forward, forward, turn left, backward. Then I press the green button to tell it to go. Let’s watch: forward, forward, turn left, backwards. It worked!” Then they each get a turn.

With the mTiny and its coding cards, I show them how we use the remote: “I tap on the yellow card to tell it I’m starting a program, then tap on the directions: forward, turn left, forward, backward. Then I tap on the green to say go. Forward, turn left, forward, backward. It worked!” Then I let them all try.


Find lots more robot activities, recommended books, and songs.

[…] Robot Programming: If / Then / Else. And a Simon Says sort of game. […]