Hi all! After moving up to a new school and taking robotics as an option,I thought I would impress my teacher by building a simple robot for thefirst lesson (tee hee!) . With the exception of playing around with theonboard LED I have never programmed it before though, so, after scrolling through the examples I added, adapted, written and produced my own program based on the digital example "button". Here it is:

*/

// constants won't change. They're used here to // set pin numbers:const int buttonPin = 2; // the number of the pushbutton pinconst int relayPin = 12; // the number of the motor reversing pinconst int motorPin = 8; // the number of the turning pin// variables will change:int buttonState = 0; // variable for reading the pushbutton status

What I was wondering is quite simple: will it work? The idea starts off similar to the schmatic shown in the example, using a micro swith instead of the tactile switch shown. If the robot drives into the wall it closes the switch. This then activates a DPDT relay wired up as an always on H-bridge and reverses the motors. After a set period of time one motor goes forward again as the relay pin goes low, then motor pin turns one of the motors off, causing the robot to turn. The motor pin then goes low and the robot sets off in a different direction to before untill it hits a wall and the whole process starts again. Thatsthe idea anyway. Will it work though?