convertire un byte in un int

ciao a tutti, sto sviluppando un applicazione con l'ausilio di una seriale con arduino.

devo scrivere il byte ricevuto dalla seriale, nell'eeprom dell'arduino, ma la funzione per scrivere l'eeprom di arduino, riceve come valore due tipi int, sia per l'indirizzo che per il valore.
se io voglio, usare il byte letto da seriale e scriverlo nella eeprom, come faccio, dato che i due tipi sono differenti??? leggo un byte dalla seriale, e devo scrivere quel numero sull'eprom, ma dovrei convertire il byte in un int?, come faccio??

No, i dati sono in formato byte. Solo gli indirizzi sono passati come int.
Questo è un esempio di codice trovato su rete.

/*
Example 21.2  Reading and writing data to Microchip 24LC256 EEPROMS over I2C
tronixstuff.com/tutorials > Chapter 21  CC by-sa v3.0
*/
#include  "Wire.h"    // for I2C
#define chip1 0x50    // device address for left-hand chip on our breadboard
#define chip2 0x51    // and the right

// always have your values in variables
unsigned int pointer = 69; // we need this to be unsigned, as you may have an address > 32767
byte d=0; // example variable to handle data going in and out of EERPROMS

void setup() {
    delay(5000);
    Serial.begin(9600); // for screen output
    Wire.begin();   // wake up, I2C!
}

void writeData(int device, unsigned int add, byte data) {
// writes a byte of data 'data' to the chip at I2C address 'device', in memory location 'add'
    Wire.beginTransmission(device);
    Wire.send((int)(add >> 8));   // left-part of pointer address
    Wire.send((int)(add & 0xFF)); // and the right
    Wire.send(data);
    Wire.endTransmission();
    delay(10);
}

byte readData(int device, unsigned int add) {
// reads a byte of data from memory location 'add' in chip at I2C address 'device'
    byte result;  // returned value
    Wire.beginTransmission(device); //  these three lines set the pointer position in the EEPROM
    Wire.send((int)(add >> 8));   // left-part of pointer address
    Wire.send((int)(add & 0xFF)); // and the right
    Wire.endTransmission();
    Wire.requestFrom(device,1); // now get the byte of data...
    result = Wire.receive();  return result; // and return it as a result of the function readData
}

void loop() {
    Serial.println("Writing data...");
    for (int a=0; a<20; a++) {
        writeData(chip1,a,a);
        writeData(chip2,a,a); // looks like a tiny EEPROM RAID solution!
    }
    Serial.println("Reading data...");
    for (int a=0; a<20; a++) {
        Serial.print("chip1 pointer ");
        Serial.print(a);
        Serial.print(" holds ");
        d=readData(chip1,a);
        Serial.println(d, DEC);
    }
    for (int a=0; a<20; a++) {
        Serial.print("chip2 pointer ");
        Serial.print(a);
        Serial.print(" holds ");
        d=readData(chip2,a);
        Serial.println(d, DEC);
    }
    delay(500);
}

come dice Leo
il EEprom di Arduino (quello interno al ATmega328) é di 1024 celle a 8Bit.
Per memorizzare qualcosa il dato deve essere di tipo Byte e l' indirizzo di tipo int perché un byte puó memorizzare solo numei fino 255.
Ciao Uwe

ok, ho capito....ma a me interessa usare solamente le locazioni tra 0 a 255.
ora io devo leggere la locazione "x" della eeprom, ma il numero "x" a me viene trasmesso da seriale, come un byte.
dato che io in arduino, per leggere il contenuto della locazione "x" ,uso EEPROM.read(), ma l'indirizzo di codesta funzione deve essere un int.
quello che io chiedo, dato che a me interessano, solo le locazioni da 0 e 255, posso inserire il valore "x"(che è un byte), come indirizzo nella funzione EEPROM.read(), cioè : EEPROM.read(x)???
si può fare?? oppure i due tipi sono incompatibili, dato che EEPROM.read() si aspetta come numero di address un int??

se così non funziona, come posso fare per ,in un certo senso, rimappare il mio byte "x" di indirizzo, in un int, adatto all' indirizzo che devo mettere nella funzione EEPROM.read()??

damosound:
quello che io chiedo, dato che a me interessano, solo le locazioni da 0 e 255, posso inserire il valore "x"(che è un byte), come indirizzo nella funzione EEPROM.read(), cioè : EEPROM.read(x)???
si può fare?? oppure i due tipi sono incompatibili, dato che EEPROM.read() si aspetta come numero di address un int??

Scusa, non avevo capito che volevi accedere alla EEPROM interna.
Sì, comunque se passi un byte come indirizzo le funzioni EEPROM.read e EEPROM.write funzionano comunque.

ok grazie!