Hi Rob,
Even though that would work for this particular application that's generally not what you want to do (ie stay in the interrupt routine). Instead you do as I showed earlier, use a flag/semaphore in the interrupt service routine which the main code reads and determines what to do.Now I just need to know how to stay in that interrupt routine until I tap the button again.
The same thing applies to your scenario with ten states. You have a variable which you increment in the interrupt (ie once very time you press the button), once it gets to 10 you reset it to zero. Then, in the main program loop you simply check the value of this variable and act accordingly. With a bit of thought and some math you might even USE the variables value directly as the delay in your loop to blink the LED.
As for the analog input it's important to understand that there is no mechanism to automatically run the ADC and detect (ie interrupt) when the voltage at the input changes. You need to write code to sample the input once every minute, second, millisecond or whatever the requirement may be.
Finally, please don't quote the full message just posted. There's really no need to have the very latest post quoted in full.
/Henrik.




Bookmarks