Go Down

Topic: Write special characters to external EEPROM (Read 1 time) previous topic - next topic

1rn07ee058

I am using this code for writing to eeprom (24lc256). How do I write special characters to the eeprom using Wire.h?

void writeEEPROM(int deviceaddress, unsigned int eeaddress, int data )
{
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.write(data);
  Wire.endTransmission();
 
  delay(5);
}


Thanks in advance

knut_ny

??  data can be whatever you decide, included 'special chars'
Ny

1rn07ee058

Data is actually timestamp obtained from rtc ds1307. i want to include / and : appropriately .

knut_ny

Ny

MorganS

Quote
Code: [Select]

 EEPROM_write(addr,'/'); 
 EEPROM_write(addr,':'); 
This is much easier to read and understand - no comments required.

Stupid question: why are you wasting valuable EEPROM memory on characters which never change? When you read the data out of the memory you should apply this formatting for the person reading it. The Arduino doesn't need these space-fillers.
"The problem is in the code you didn't post."

1rn07ee058

problem solved thanks for your replies. :)

I used This,

int thisbyte = 124;
int thisbyte2 = 58

Serial.write(thisbyte); //prints "|" in the serial monitor.
Serial.write(thisbyte2); //prints ":" in the serial monitor.

Go Up