Dúvida EEPROM , será que alguém me responde , dessa vez ?, rsrs

   Até agora , ninguém  nunca respondeu nenhum topico meu ,hehe esse já é o quarto com um assunto novo , os outros já consegui resolver na marra hehe, espero que alguém pelo menos responda que não sabe , por favor rs.

   Deixando as brincadeiras de lado , gostaria de saber se é possivel armazena uma variavel na EEPROM com um valor acima de 255, ex uma senha de 6 digitos , quando eu tento guarda um valor acima de 255 ele até compila , mas quando eu leio esse valor , vem outro valor aleatorio ???, a dúvida é essa  ai , respondam pelo menos pra dizer q naum sabem e quem souber por favor da um ajuda ai , sou novato no arduino estou migrando do 8051 , e essa foi a melhor escolha que fiz ,com esse vasto material na net , da pra fazer tudo  ou quase tudo com essa plaquinha , blz valeu. 

Exibições: 299

Responder esta

Respostas a este tópico

Olá,

Veja este tutorial: http://labdegaragem.com/profiles/blogs/tutorial-usando-a-eeprom-do-...

É sempre bom tentar ver os tutoriais aqui do site antes de abrir uma nova discussão, normalmente as dúvidas mais comuns podem ser sanadas com o material postado lá, talvez esta sejuma das razões para a falta de respostas aos outros tópicos.  :)

Abraço.

   Bacana amigo , como sou novato ainda estou meio perdido , me adaptando ainda , mas sem grandes dificuldades ainda, valeu pela resposta , já sei onde procurar agora rs antes de posta algo  , mais se você não me desse essa simples dica talvez demoraria um pouco mais pra descobrir , obg , valeu.

Beleza, qualquer dúvida, pergunte mesmo.  :)

Se voce usar uma EEPROM i2c como uma 24LCxx, voce pode usar as seguintes classes para escrever por byte, inteiro, longo, ou alpha:

// ******************* READ BYTE EEPROM ********************** //
byte WireEepromReadByte(int theDeviceAddress, unsigned int theMemoryAddress) {
byte theByteArray[sizeof(byte)];
WireEepromRead(theDeviceAddress, theMemoryAddress, sizeof(byte), theByteArray);
return (byte)(((theByteArray[0] 0)));
}
// ******************* WRITE BYTE EEPROM ********************** //
void WireEepromWriteByte(int theDeviceAddress, unsigned int theMemoryAddress, byte theByte) {
byte theByteArray[sizeof(byte)] = {
(byte)(theByte >> 0) };
WireEepromWrite(theDeviceAddress, theMemoryAddress, sizeof(byte), theByteArray);
}
// ******************* WRITE INT EEPROM ********************** //
void WireEepromWriteInt(int theDeviceAddress, unsigned int theMemoryAddress, int theInt) {
byte theByteArray[sizeof(int)] = {
(byte)(theInt >> 8), (byte)(theInt >> 0) };
WireEepromWrite(theDeviceAddress, theMemoryAddress, sizeof(int), theByteArray);
}
// ******************* READ INT EEPROM ********************** //
int WireEepromReadInt(int theDeviceAddress, unsigned int theMemoryAddress) {
byte theByteArray[sizeof(int)];
WireEepromRead(theDeviceAddress, theMemoryAddress, sizeof(int), theByteArray);
return (int)(((theByteArray[0] 8)) | (int)((theByteArray[1] 0)));
}
// ******************* READ EEPROM ********************** //
void WireEepromRead(int theDeviceAddress, unsigned int theMemoryAddress, int theByteCount, byte* theByteArray) {
for (int theByteIndex = 0; theByteIndex < theByteCount; theByteIndex++) {
Wire.beginTransmission(theDeviceAddress);
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 8));
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 0));
Wire.endTransmission();
delay(5);
Wire.requestFrom(theDeviceAddress, sizeof(byte));
theByteArray[theByteIndex] = Wire.read();
}
}
// ******************* WRITE EEPROM ********************** //
void WireEepromWrite(int theDeviceAddress, unsigned int theMemoryAddress, int theByteCount, byte* theByteArray) {
for (int theByteIndex = 0; theByteIndex < theByteCount; theByteIndex++) {
Wire.beginTransmission(theDeviceAddress);
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 8));
Wire.write((byte)((theMemoryAddress + theByteIndex) >> 0));
Wire.write(theByteArray[theByteIndex]);
Wire.endTransmission();
delay(5);
}
}

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço