Rabu, 16 April 2014

ARDUINO - Comparator External Example

int indikator=13;

boolean comparatorOutput;
ISR(ANALOG_COMP_vect)
{
  comparatorOutput=true;
}
void setup()
{
  pinMode(indikator, OUTPUT);
  ADCSRB = 0;
  ACSR =_BV(ACI) | _BV(ACIE) | _BV(ACIS1);
}
void loop()
{
  if (comparatorOutput==true)
  {
    digitalWrite(indikator, HIGH);
    comparatorOutput = false ;
  }
  else
  {
    digitalWrite(indikator, LOW);
  }
}

Tidak ada komentar:

Posting Komentar