University of Northampton: Junkbots

Task 6

 

 

 

Build and program a robot that can take a junk that starts just in front of the robot into a containment area, which is marked with a black line, and move the robot back behind the safety line.

Move the junk in a straight line and use the sensors to stop the robot when the junk is in the containment area. Move the robot back to the beginning.  The code to do this has being started on the following page.

 

Programming features: Every thing between

for(;;)

                          {   

                      } gets repeated

while(robot.checkLight(1)==false)

                                                               {

}

Gets repeated while the light sensor is NOT on the black line

 

 

 

You task is to add instructions (see the previous page) in place of the lines marked with // to control the robot and put the ‘junk’ into the containment area marked.

 

As part of this task you might want to add extras  to the robot to control where the junk goes. No arms, scoops, etc are provided you need to use junk lying around to add to the robot.

 

The sensors are light sensors and measure light levels. They have been set-up so that if there is a black line underneath it , a value ‘true’ is sent to the robot. If the surface under the sensor is white then it will send back a ‘false’ value to the robot. By using these, the robot knows if there is a black line under the sensor.

if (robot.checkLight(1)==true)

                                                   {  

} When the sensor is on the line the what ever is between the brackets is carried out but not repeated