Take the 2-minute tour ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

I have an Arduino UNO. I've been reading about Pin Change Interrupts, and one vector covers the Analog Pins. However, is it possible to trigger interrupts using analog pins as analog inputs (not digital)?

I actually want to analogRead() a potenciometer inside the ISR.

This is my code so far, http://pastebin.com/ykpp78GB

And my circuit is just 2 potenciometers connected to pin A0 and A1.

share|improve this question

1 Answer 1

It is not possible to trigger an interrupt when an analog input has reached a threshold on any tinyAVR or megaAVR. It is possible to trigger an interrupt when an analog input of an AVR XMEGA with the event system.

It is possible to use the built-in analog comparator on the ATmegaXX8 and ATmegaXXU4 in the Uno, Leonardo, and comparable boards to trigger an interrupt when an internal or external threshold has been met. It is only possible to compare to an internal threshold on the Mega, Mega 2560, or comparable boards since the pin for the external threshold is not broken out, although actual breakout boards for the ATmegaXXX0/1 will have the pin broken out.

In all cases, examine the appropriate datasheet (in particular the "Analog Comparator" section) as well as the pin mappings on the Arduino website for full details.

share|improve this answer
    
What I want to do is to analogRead() a pot inside the ISR. I have an Arduino UNO. –  redraw Dec 5 '14 at 2:10
    
Well, I'm thinking that maybe I should read those analog values inside a timer interrupt. Considering I'm using some delays inside the loop() function. –  redraw Dec 5 '14 at 2:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.