Purpose:

The purpose of this lab is two fold. First to verify that you can determine if the proximity sensors on the top level of your robot are detecting anything nearby. Second to do something with that awareness.

It will be helpful if you also have a TV or audio system remote for one of the activities.

Procedure:

As you begin each lab from here on out the assumption is that you have connected your Qbot to your computer and you have the IDE running and talking to the Qbot.

  • Let's start with a simple experiment. Hold your robot up in the air so it doesn't run away and turn it on. This way it doesn't matter what sketch you have loaded at the moment. Don't be startled if the wheels move and drop your bot -- it might get hurt. With the robot turned on bring your finger near the IR sensor that is under the top plate just 'outside' of the 'headlights'. When you bring your finger close enough you should see a blue LED turn on underneath the top. Experiment with different materials to reflect the IR light. Does paper work as well as plastic? If you angle the reflector does the light turn out? Find a TV remote and point it at the IR sensor and watch the LED. What does the LED do as you press different buttons on your remote? Can you tell the difference (I would be surprised)? What if you use a black paper or plastic that isn't shiny? Can you explain why the response of the IR sensor changes? If you have a red laser you can try that as well. You might also notice that there are two more IR sensors on the bottom of the robot for looking at the ground.
  • Now that you have a sense for what sorts of reflections are noticed by the IR sensors lets create a sketch to test the sensors. The code for the IR test sketch is on this linked page. Once you have the code uploaded use the serial monitor to check to make sure the left and right sensors are correctly labeled. Notice that the IR sensor gives a 1 when it is off and a 0 when it is on. This understandably feels a little backward but that's how its set up.
  • Teach your robot to do something, anything: What can you teach your robot to do when one of the IR sensors is activated? You could combine it with the ultrasonic sensor to creep in very close to a wall before stopping (the ultrasonic sensor starts to freak out a few cm from the wall). You could teach your robot to turn right when the left sensor is activated by you (with your hand or some other reflective object). I don't think you can teach your robot to follow the TV remote because it's not consistent (I tried:))
  • Now for a new challenge! Here is the code for a sketch that is badly commented. If you load this sketch onto your robot you can test what it does. Start the robot on the floor near a wall. Point the robot at an angle so the left side will get close to the wall first. Let it go and watch what it does. Now go into the code and add comments to the loop portion of the sketch that describe what the sections are doing. You need to add at least 6 thoughtful multiline comments to the sketch, with your initials, that describe the purpose of a section of the code. NOT just 6 lines of comments please. Reading the left and right sensors counts as one thing! Be careful. If the robot goes into the sunshine it will get confused -- why might that be?

 

LAB DELIVERABLES: (Turn in on Bb)

I) What did you 'teach' your robot to do? Describe and then include your sketch in your lab report.

II) Describe what the unknown sketch appears to do and include your comments in the loop portion of the sketch. Be sure your initials appear for each comment.