stickyBUG Code

The following sample code requires the eepromBUG library.

Source Code

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

 // ioBUG object
eepromBUG bug = eepromBUG();

// program setup... 
void setup() {
   bug.begin(EEPROM_BUG_ADDRESS);
   Serial.begin(9600);

   const unsigned int SIZE_ARRAY = 200;
   byte array[SIZE_ARRAY];

   // clear eeprom and init array...
   for (byte i = 0; i < SIZE_ARRAY; i++) {
      bug.writeByte(i, 0);
      array[i] = i + 10;
   }

   // write the array
   bug.writeArray(0, array, SIZE_ARRAY); 

   for (byte addr = 0; addr < SIZE_ARRAY; addr++) {
      byte data = bug.readByte(addr);
      Serial.print(addr);
      Serial.print(" : ");
      Serial.println(data);
   }
}

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