-
Notifications
You must be signed in to change notification settings - Fork 0
EEPROM
Tiogaplanet edited this page Jul 28, 2018
·
5 revisions
MiP has a built-in electrically erasable programmable read-only memory (EEPROM) which can be read from or written to. The EEPROM provides up to eight bytes of accessible memory.
void setUserData(uint8_t addressOffset, uint8_t userData)
Stores one byte of user data to the offset specified. Valid offsets are 0x00-0x0F.
- addressOffset is the address offset at which to write the user's data.
- userData is the one byte of data to be written to EEPROM.
Nothing
#include <mip.h>
MiP mip;
// Use an offset between 0x00 and 0x0F.
const uint8_t eepromAddressOffset = 0x00;
// Try different hex values here to see them stored and
// recovered from EEPROM.
uint8_t secretPassword = 0x0D;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("ReadWriteEeprom.ino - Writes data to EEPROM and reads it back."));
Serial.print(F("Original password: "));
Serial.println(secretPassword, HEX);
// Power-off the MiP, comment out this line, recompile and load to the ProMini-Pack to see EEPROM
// data preserved across power cycles.
mip.setUserData(eepromAddressOffset, secretPassword);
// "Scramble" the secret password.
secretPassword = 0xFF;
Serial.print(F("Scrambled password: "));
Serial.println(secretPassword, HEX);
Serial.print(F("Recovered password: "));
Serial.print(mip.getUserData(eepromAddressOffset), HEX);
}
void loop() {
}uint8_t getUserData(uint8_t addressOffset)
Reads one byte of user data from the address offset specified. Valid addresses are 0x00-0x0F.
- addressOffset is the address at which to read stored data.
- The contents of the EEPROM read from the given address offset.
#include <mip.h>
MiP mip;
// Use an offset between 0x00 and 0x0F.
const uint8_t eepromAddressOffset = 0x00;
// Try different hex values here to see them stored and
// recovered from EEPROM.
uint8_t secretPassword = 0x0D;
void setup() {
// First need to initialize the serial connection with the MiP.
bool connectResult = mip.begin();
if (!connectResult) {
Serial.println(F("Failed connecting to MiP!"));
return;
}
Serial.println(F("ReadWriteEeprom.ino - Writes data to EEPROM and reads it back."));
Serial.print(F("Original password: "));
Serial.println(secretPassword, HEX);
// Power-off the MiP, comment out this line, recompile and load to the ProMini-Pack to see EEPROM
// data preserved across power cycles.
mip.setUserData(eepromAddressOffset, secretPassword);
// "Scramble" the secret password.
secretPassword = 0xFF;
Serial.print(F("Scrambled password: "));
Serial.println(secretPassword, HEX);
Serial.print(F("Recovered password: "));
Serial.print(mip.getUserData(eepromAddressOffset), HEX);
}
void loop() {
}🔗 Quick Links: Main Repository • Report an Issue • Wiki Home
An open-source API for the WowWee MiP Robot. Licensed under Apache-2.0.
- MiP
- MiPChestLED
- MiPClapSettings
- MiPDebug
- MiPHardwareInfo
- MiPHeadLEDs
- MiPIRDongleCode
- MiPSoftwareVersion
- MiPStatus
- MiP_Battery
- MiP_ChestLED
- MiP_Clap
- MiP_EEPROM
- MiP_Gesture
- MiP_HeadLEDs
- MiP_Infrared
- MiP_Mode
- MiP_Motion
- MiP_Odometer
- MiP_Position
- MiP_Radar
- MiP_Serial
- MiP_Shake
- MiP_Sound
- MiP_Version
- MiP_Weight
- MiP_WiFi