In this project you program your robot to stay inside a white area that has a black zone around the outside of it.
Whenever the robot starts to stray into the black zone, it has to back up, turn around and head off in a different direction.
This movie will show you how to create the code for the sheep pen robot.
The code for this project is very similar to that in Unit 5: Controlling a motor with light. In this project you are still controlling a couple of motors with a light. The key to it is the if statement. In this case if the sensor goes low then you back up and turn, else you just go forwards.
If you need to remember how to make a motor go look back at Unit 6: Reversible motor.
Remember: Your motors may not be connected to the same pins as the ones in Unit 6.
If you need to find out what pins your motor is connected to look at WHICH PINS CONTROL YOUR MOTOR.