Still can't force it to work...
Code in playground doesn't work. All I've got -
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿMemory written
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ and so on.
I test this
#include <Wire.h> // specify use of Wire.h library.
// address in 24ATC04 values from 0 to 511.
int BEGIN = 0;
int ADDR[] = {
0x50, 0x51, 0x52, 0x53, 0x54};
char* TEST[] = {
"Chip0", "Chip1", "Chip2", "Chip3", "Chip4"};
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // setup serial for output
// send test message "Arduino"
Wire.beginTransmission(ADDR[0]); // connect to 24LC04 device address
Wire.send(BEGIN); // beginning address within EEPROM
Wire.send(TEST[0]);
Wire.endTransmission();
delay(10);
}
void loop()
{
Wire.beginTransmission(ADDR[0]); // link to 24LC04
Wire.send(BEGIN); // must act as a position pointer
Wire.endTransmission();
delay(10);
Wire.requestFrom(ADDR[0], 5); // request 5 bytes from slave device 24LC04
delay(10);
// below will loop until 5 bytes are received.
while(Wire.available()) // slave may send less than requested
{
char c = Wire.receive(); // receive a byte as character
Serial.print(c); // print the character
}
Serial.print("\n"); // next line
delay(1000); // wait one second.
}
This code works, but it only writes and reads first 5 bytes of memory, while I need read all bytes.
How to do that? I stumbled for the third day :-/
24c04 has 32 pages each of 16 bytes.