I've been successfully testing the analog comparator on an Arduino Uno using pin 7 (AIN1) and setting the positive input of the comparator to use the internal voltage:
pinMode(7,INPUT);
ACSR = B01011011; // comparator interrupt enabled and tripped on falling edge.
ISR(ANALOG_COMP_vect)
{
// Interrupt code here
}
}
I now want to move this code to a Mega 2560. Looking at the pin mapping of the ATmega2560 it appears to use pin 5 for AIN1.
Will the comparator work the same with the Mega 2560 by just changing the input pin from 7 to 5?