#include <EEPROM.h>
void print_eeprom_contents() {
for (int i = 0; i < EEPROM.length(); i++) {
byte data = EEPROM.read(i);
if (i % 16 == 0) { // group output by 8 characters per line
Serial.println();
//Serial.print("0x");
//Serial.print(i, HEX);
//Serial.print(i);
printFormattedNumber(i);
Serial.print(" : ");
}
Serial.print((char)data);
}
}
void fillRandomData(){
randomSeed(analogRead(0)); // Seed the random number generator with a random value from the analog input
for (int i = 0; i < EEPROM.length(); i++) {
char c;
/*
if (i % 3 == 0) {
c = '0' + random(10); // Generate a random digit
} else if (i % 3 == 1) {
c = 'A' + random(26); // Generate a random uppercase letter
} else {
c = 'a' + random(26); // Generate a random lowercase letter
}
*/
c = '0' + random(10); // Generate a random digit
EEPROM.write(i, c); // Write the character to the current address in EEPROM
}
Serial.println("EEPROM filled with random characters.");
}
void printFormattedNumber(int num) {
char buffer[5]; // Buffer to hold the formatted number
sprintf(buffer, "%04d", num); // Format the number with leading zeros
Serial.print(buffer); // Print the formatted number
}
void setup() {
Serial.begin(9600);
fillRandomData();
print_eeprom_contents();
}
void loop() {
// Do nothing
}