Interruptions

This post shows converting an analog input to digital by using a comparator:

Then that could trigger an interrupt. The example code on that page detects the interrupt.