Interrupt on an analog pin.

How can one register an interrupt on an analog pin.
I have an IR reciever set up on analog pin 0 and I want to an interrupt whenever it reads LOW.

I did a bit of looking and apparently a comparator is used, but I have no clue on how to register the interrupt with it… >.< … this one below.

void setup() {
  ACSR = 
  (0<<ACD) |   // Analog Comparator: Enabled
  (0<<ACBG) |   // Analog Comparator Bandgap Select: AIN0 is applied to the positive input
  (0<<ACO) |   // Analog Comparator Output: Off
  (1<<ACI) |   // Analog Comparator Interrupt Flag: Clear Pending Interrupt
  (1<<ACIE) |   // Analog Comparator Interrupt: Enabled
  (0<<ACIC) |   // Analog Comparator Input Capture: Disabled
  (1<<ACIS1) | (1<ACIS0);   // Analog Comparator Interrupt Mode: Comparator Interrupt on Rising Output Edge



I do apologise if my question makes no sense at all 3:


Is this a viable replacement???

int reading;
boolean go = False;
volatile int npulses = 0;
volatile unsigned long lasttime = 0;
volatile int distance = 0;

void countPulse() {
  //execute pulse counting code

void setup() {
  pinMode(0, INPUT);

void loop() {
  reading = analogRead(0);
  if (reading ==  0) {  // For the IR reciever the value drops to 0/LOW when recieving a signal
    go = True;
  if (go == True) {
    go = False;

The analog also serve as digitl pins, you shouldn’t need the comparator unless you are trying to trigger as a certain low level, rather than the normal logic low

You code is not a replacement for posted example. Using hardware interrupt from Analog Comparator, means you would never miss an events when voltage drops below certain level (bandgap 1.1V on UNO board).
"reading = analogRead(0);" this line of code get readings only when it's executed, moments earlier or later and you would never register that there was a pulse. IR coming in quite fast 38 kHz, it's even higher freq. than analogRead could normally comprehend.