Home | Screen shots | Documentation | Download | Contact | Blog

Analog comparator

Sometimes we come into situations where we need to work with analog input. The arduino supports two ways of working with analog input. Either simple through the analog comparator, or complex through the analog to digital converter.

Sometimes we just need to know wether an analog signal is lower or higher then an other signal. The arduino has two pins you can use to easily detect this. The pins are called AIN0 and AIN1.

Unless the ACD bit in the ACSR register is set the arduino will constantly compare the two values. When the output on the AIN0 pin is higher then the voltage on the AIN1 pin, the ACO bit in ACSR is set (1). In this case the interrupt flag ACI will also be set. If the ACIE bit in ACSR and the I bit in the status register is set an interrupt will occur.

To set the values in the emulator, the following screen is used:

analog comparator

We can fill out our two voltages and when the voltage on AIN0 is higher then the voltage on AIN1, ACO will be set and ACI will be set. If we fill out the value for ACIE to be 1 in the registers, then an interrupt will occur.


  COPYRIGHT 2010 Imre Leber