Analog comparator

Back to start page

ATmega328/P has one analog comparator. The comparator has two inputs on pins AIN0(+)/PD6/D06 and AIN1(-)/PD7/D07. In addition, all other AD pins can also be used as comparator (-)input (if the AD converter is turned off). For comparator (+)input, an internal 1.1 V reference can be used. The comparator output can (only) be read programmatically, either as bit  ACO  or with interrupt (ANALOG_COMP_vect).

The test program examines the comparator with a potentiometer connected to AIN1/PD7 (-)input and the internal reference coupled to the (+)input. The comparator output is displayed with Arduino's built-in LED on the PB5/D13. The test program uses interrupt.

The full program is available here:


Back to start page

 


William Sandqvist    willsandqvist@gmail.com