Pages: [1]   Go Down
Author Topic: Eprom wright  (Read 433 times)
0 Members and 1 Guest are viewing this topic.
Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

here is the problem

Code:
#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()
{
}

Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 240
Posts: 24452
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: