Skip to content

Instantly share code, notes, and snippets.

@dadecoza
Created May 9, 2024 15:15
Show Gist options
  • Save dadecoza/57b4fe0a8252a888b06a89fe4a967c26 to your computer and use it in GitHub Desktop.
Save dadecoza/57b4fe0a8252a888b06a89fe4a967c26 to your computer and use it in GitHub Desktop.
Arduino EEPROM Test
// Flashing LED indicates an error
#include <EEPROM.h>
unsigned char fillchar = 0xFF;
int fault = 0;
void setup() {
pinMode(13, OUTPUT);
// put your setup code here, to run once:
for (int i=0; i<1024; i++) {
EEPROM.write(i, fillchar);
}
for (int i=0; i<1024; i++) {
unsigned char b = EEPROM.read(i);
if (b != fillchar) {
fault = 1;
break;
}
}
}
void loop() {
// put your main code here, to run repeatedly:
if (fault) {
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment