05 Mission Instructions

Your mission is to create a robot that starts an interaction when a human approaches.  Your robot should be friendly and act as naturally as possible.

5. Code: Responsive Robotics

Now we need to think about when the robot will wave.  A robot that just randomly waves - or only waves when you press “Run” is not the most useful or easy-to-use. Instead, we’re going to use the Distance sensor so when the robot detects an object nearby, it begins to wave and interact.



If you only use an [if-do] loop, however, the robot will only check the distance sensor one time. Remember to add a [forever-do] loop to your program!







But what if the human (or a pet, maybe?) begins to walk away from the robot when it starts waving?  In human-centered robotics, it’s important that robots are programmed to stop their behavior if it’s not getting the right response from the people around it. To incorporate this, we’ll need to add a new command [break out of loop]. Let’s start by having the robot check again for an object nearby each time it completes one cycle of its wave. (Hint: that means you’ll need another [if-do] loop inside your repeat loop!)