isr analog comparator problem


hello, i'm trying star interumpt when sensor detect object around 53cm, ir distance sensor send voltage greater 1,1v  (wich reference), means ir send  1,1v @ 54cm voltage greater 1,1v between 20cm-53cm thats want interupt occur , datasheet got 3 modes of compar ;rising (11),failing(10) , change(00) problem 3 of them give me same answer generate interumption between 54cm , 150cm , interumpts stop @ 20cm-53cm.
when see serial monitor gives me interupt when isr(analog_comp_vect) returns 1 got oposite here code



code: [select]

int interrupt_inputpin = 7;
volatile int interrupt_var;
//---------------------------------------------------
void setup()
{
 
  serial.begin(9600);
  pinmode(interrupt_inputpin, input);
   pinmode(6, input);
  acsr = b01011010;
  interrupt_var = 0;
}
//---------------------------------------------------
void loop()
{
  if(interrupt_var == 1)
  {
    serial.println(" +++++++ objet ++++++");
    interrupt_var = 0;
  }
  else
  {
    serial.println(" waiting ");
  }
  delay(200);
}
//------------------------------------------------------------

//-----------------------------------------------------------
isr(analog_comp_vect)
{
  interrupt_var = 1;
}
//------------------------------------------------------------

code: [select]
  acsr = b01011010;

can re-do line symbolic constants please? knows bits are?

see: http://www.gammon.com.au/forum/?id=11916


Arduino Forum > Using Arduino > Programming Questions > isr analog comparator problem


arduino

Comments