Go Down

Topic: Eprom wright (Read 1 time) previous topic - next topic


Hi all would be grateful for a bit of help here. I though this bit of my project would be easy but didn't read the eprom  page well enough. Anyway it's fairly simple i think, i just don't know how to do it. Basically how do i convert a int to 2 8 bit bytes. I need to store some int's in the eprom but it's only bytes. Their is enough room just i just need pointing in the right direction for a simple way of doing the conversion to the eprom and back again. Cheers :)

here is the problem

Code: [Select]

#include <EEPROM.h>

unsigned int Var_1=1000;    // 2 bytes
unsigned int Un_Var_1=1000; // ..

unsigned int Var_2=1000;    
unsigned int Un_Var_2=1000;

unsigned int Var_3=1000;    
unsigned int Un_Var_3=1000;

int Speed=500;

uint8_t Slot_A=0;        // 1 byte
uint8_t Slot_B=4;
uint8_t Slot_C=7;

                     // 17 bytes in all

void setup()
   EEPROM.write(0, Slot_A);
   EEPROM.write(1, Slot_B);
   EEPROM.write(2, Slot_C);
  // EEPROM.write(3, Var_1);   // Whats the best way to do this
                              // presumably i can split it
                              // into two bytes and then retreve
                              // it in a similar way

void loop()


highByte and lowByte are a start.
Or the EEPROManything library/templates.


Ahh yes i think i'd seen the high byte low byte some were just couldn't quite remember. Cheers i think that's what i'm looking for. Will check the other thing as well.

Go Up