stickyBUG Code

The following sample code requires the temperatureBUG library.

Source Code

// import the wire library...
#include <Wire.h>
#include "temperatureBUG.h"

 // temperatureBUG object
temperatureBUG bug = temperatureBUG();

// program setup...
void setup() {
   bug.begin(TEMP_BUG_ADDRESS);
   bug.setResolution(TEMP_RESOULTION_10_BIT);
   bug.setAlarmLow(23);    // alarm switch off when below this value
   bug.setAlarmHigh(24);   // alarm switch on when over this value
   Serial.begin(9600);
}

// main program loop...
void loop() {  

   if (bug.isAlarm()) {
      Serial.print(bug.getValueStr());
      Serial.println(" degrees C - *** ALARM ***");
   } 
   else {
      Serial.print(bug.getValueStr());
      Serial.println(" degrees C");
   }
   delay(5000);
}