void interrupt isr (void)
// This function will be automatically called upon an interrupt
{
if (save_data ( ) ==0)
// If interrupt was caused by real time clock, return. If
{return;}
// interrupt was caused by bumper, save function variables
// being used by main() so they can be restored upon returning
// from interrupt.
pause (5);
// Pause 5 msec to allow for bumper switch contact bounce
if ((PORTB & 0x01) == 1)
// Confirm valid bumper interrupt
{
INTF = 0;
restore_data ( );
//Restore function variables used in main()
return;
}
output_low ('c', 0);
//STOP the Motors! I’ve bumped into something.
output_low ('c', 5);
output_low ('c', 3);
output_low ('c', 4);
pause (50);
//Always allow some time (50ms) for the motors to stop
/*YOUR CODE GOES HERE - I.e., Check which
bumper(s) hit and take evasive motor action. SEE
IMPORTANT NOTES BELOW */
if ((PORTB & 0x01) == 1)
// If all bumpers have cleared their obstacles
{
INTF = 0;
// Clear interrupt flag bit
}
restore_data ( );
//Restore function variables used in main()
return;
}