Interupts

@ CosineKitty....

But how can we generate internal interrupts like when a variable reaches a particular value. I actually want to generate interrupt when the distance of my robot from wall reaches a threshold value. obviously this threshold value is calculated in software (Arduino environment).

Are there any internal interrupts in Atmega328?

Thanks!