Hi
Would appreciate any hint regarding this problem. I'm working on a robot-vehicle sketch at the moment. The vehicle is driven around using two motors and it has a lift and a conveyor belt (each driven by a separate motor) for handling load. There is also a number of proximity and contact sensors to control all of these motors and vehicle movement. The main program is placed in a loop and it consists of a series of motor runs controlled either by a while loop or delay() commands. Here's a sample pseudo code:
void loop () {
while (sensor_A == LOW) {
drive lift motor up;
}
drive LHS_motor;
drive RHS_motor;
delay(3000)
stop LHS_motor;
stop RHS_motor;
etc...
}
The whole loop takes about 90sec which is the time for the vehicle to approach the loading station, pick up the load, move to the unloading station, unload and come back to the starting point.
Here's the problem: The vehicle is equipped with a proximity sensor which is to detect unexpected obstacles along the way. What I want is to implement this in the code in such a way that when this sensor is active (i.e. obstacle detected) the main code would simply pause (all motors to stop, the vehicle stops dead) at whatever point the main loop may then be and then resume when the obstacle is removed. I'm not sure if I should use interrupts for this as I don't want any particular action to be undertaken upon the sensor's signal but simply to pause the program and the stopping time required is not at the order of micro seconds.