hello, i'm trying to star an interumpt when my sensor detect an object around 53cm, the IR distance sensor send voltage greater then 1,1v (wich is the reference), 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.
when i see the serial monitor it gives me an interupt when the ISR(ANALOG_COMP_vect) returns 1 but what i got is the oposite here is my code
what i ment is when the ISR(ANALOG_COMP_vect) occur the interrupt_var == 1 then the message "i got an interupt" is written but what i have is "waiting" when i know that voltage from the IR is higher from the refrence.
so the last two bits are the ones to change the comp technique from :
rising ( ACIS1=1, ACIS0=1) when IR<refrence
failing ( ACIS1=1, ACIS0=0) when IR>refrence
change ( ACIS1=0, ACIS0=0) when IR =! refrence
I'm not going to guess what you have done. Sketch your wiring. For example after searching for that sensor:
(note: this sensor draws current in large, short bursts, and the manufacturer recommends putting a 10 µF capacitor or larger across power and ground close to the sensor to stabilize the power supply line)