hello, i’m trying to star an interumpt when the IR send voltage greater then 1,1v (wich is acbg), it means the IR send 1,1v at 54cm so a voltage greater then 1,1v is between 20cm-53cm thats where i want the interupt to occur , from the datasheet i got 3 modes of compar ;Rising (11),failing(10) and change(00) but the problem is that the 3 of them give me the same answer they generate an interumption between 54cm and 150cm and the interumpts stop at 20cm-53cm
#include <avr/interrupt.h>
void setup()
{//i use arduino nano
pinMode(7,INPUT);
Serial.begin(9600);
ACSR = B01011010;
//analog interrupt example with the nano
//set the ACSR (analog comparator control and status register)
//ACSR - [ACD, ACBG, ACO, ACI, ACIE, ACIC, ACIS1, ACIS0]
//[ACD: anlog comparator, ACBG: analog comparator bandgap select: AIN1 is applied to positive input
//ACO: analog comparator output, ACI: analog comparator interrupt flag: clear pending interrupt
//ACIE: analog comparator interrupt:enable ,ACIC: analog comparator input capture: disable
//ACIS1: enable for rising edge, ACIS0: enable for rising edge
//ACIS1: disable for toggle, ACIS0: disable for toggle]
}
void loop()
{
}
ISR(ANALOG_COMP_vect)
{
Serial.println("Interrupt Executed!");
}