stickyBUG Code

The following sample code requires the expanderBUG library.

Source Code

// import libraries...
#include <Wire.h>
#include <expanderBUG.h>

 // expanderBUG object
expanderBUG bug = expanderBUG();

// program setup...
byte outputVar = 1;
void setup() {
   Serial.begin(9600);
   bug.begin(EXP_BUG_ADDRESS);  // set bug address
   bug.setConfig(B11111111);    // set all pins to input
}

// main program loop
void loop() {
   if (bug.inputChanged()) {
      byte value = bug.getInput();
      Serial.print("input = ");
      for (byte pad = 0; pad < 8 - String(value,BIN).length(); pad++) Serial.print("0");
      Serial.println(value, BIN);
   }
}