s3  

 

Learn to program

 
  Scribbler assignments ::

 

 
 

Assignment 12 - Obstacle avoidance

 

You have used the infrared sensors under the robot to see a black line, and to stop when the robot sees it.

Now you will use the infrared sensor in front of the robot to see obstacles, and avoid them.

obstacle sensor

The emitters bathe the scene in front of the robot, one on the front
left, the other on the front right. The detector receives reflected light coming back from an object or surface
that’s nearby.


By alternating the pulses of infra-red light between left and right emitter, the detector can tell whether the
object is ahead to the left or the right, and your program can read out this information.
For example, if the right emitter sends out light and the detector receives it back from the “bounce”, it
knows that an object is ahead to the right.

obstacle 2

 

Upload the program to your S2 and test.

Put your hand in front of the S2 on one side, then the other, and then directly in front.

Put your S2 near a wall, does it behave as expected?

Repeat this until you have a clear idea of how the sensors work.

Assignment 12

Modify the program to do the following:

Program the robot to move forward...
a. When an object is in front of the robot (detected by BOTH sensors), back up a little, turn around 180 degrees and go straight
the other way.
b. When an object is seen by a left or right sensor (just ONE sensor), back up a little, turn 90 degrees away from that side and then
go straight.
c. When no object is seen, just keep going straight.

 

When you run this new program, the robot should move forward, but avoid obstacles.

Save it to a folder on your computer as obstacleyourname.

To turn it in, look at the instructions below:

  • Go to Google Drive
  • Open the Class Program folder in 'Shared with me'
  • Open your class folder and assignment folder
  • Click on the "New" button on the top left
  • Upload the program from your computer

 

 

 

Write a Reflection on what you have learned.