The seesaw firmware that ships with the ATtinyxxx breakouts provides access to the 128 byte EEPROM. This example reads from and writes to the EEPROM.

Follow the steps on the Arduino page to get set up.

Example Code

Open up File -> Examples -> Adafruit Seesaw -> EEPROM.

/*
 * This example shows how to read and write EEPROM data. Try writing
 * then removing power from both devices, commenting out the write, and
 * uploading again.
 */

#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

void setup() {
  uint8_t eepromval;
  
  Serial.begin(115200);
  
  while (!Serial) delay(10);   // wait until serial port is opened
  
  if(!ss.begin()){
    Serial.println(F("seesaw not found!"));
    while(1) delay(10);
  }
  
  Serial.println(F("seesaw started OK!"));

  Serial.print(F("Initial read from address 0x02...0x"));
  eepromval = ss.EEPROMRead8(0x02);
  Serial.println(eepromval, HEX);

  Serial.println(F("Incrementing value to address 0x02"));
  ss.EEPROMWrite8(0x02, eepromval+1);

  Serial.print(F("Second read from address 0x02...0x"));
  Serial.println(ss.EEPROMRead8(0x02), HEX);
}

void loop() {
  //DONT WRITE EEPROM IN A LOOP!!!! YOU WILL DESTROY YOUR FLASH!!!
}

Once you've successfully uploaded the sketch to your board, open the Serial Monitor (Tools->Serial Monitor), and see the info printed out!

This guide was first published on Oct 20, 2021. It was last updated on Apr 18, 2024.

This page (EEPROM) was last updated on Apr 17, 2024.

Text editor powered by tinymce.