I'm trying to connect EEPROM chip 24LC01B to Arduino Nano 328P, write data to it, read and display it in Serial Monitor.
Serial Monitor shows only
Writing... Reading...
I can't figure out what the problem is.
#include <Wire.h>
#define memoryAddr 0x50
byte in=0x00;
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
void loop()
{
Serial.println("Writing...");
Wire.beginTransmission(0x50); // This is the 24LC01B device address
Wire.write(0x0); // Start writing at address 0
Wire.write("Hell"); // Send 4 bytes
Wire.endTransmission();
delay(100); // Without a short delay, the EEPROM is still
// writing when you start to write the next block
// Feel free to experiment with the delay length
Wire.beginTransmission(0x50);
Wire.write(0x4); // Write next four bytes starting at address 4
Wire.write("o Wo");
Wire.endTransmission();
delay(100);
Wire.beginTransmission(0x50);
Wire.write(0x8); // Write last four bytes starting at address 8
Wire.write("rld!");
Wire.endTransmission();
delay(100);
Serial.println("Reading...");
Wire.beginTransmission(0x50); // Now we're going to read it back
Wire.write(0x0); // Sending address 0, so it knows where we'll want
Wire.endTransmission(); // to read from
Wire.requestFrom(0x50,12); // Start new transmission and keep reading for 12 bytes
while(Wire.available())
{
char c = Wire.read(); // Read a byte and write it out to the Serial port
Serial.print(c);
}
Serial.println();
delay(5000);
}
Here is how I've connected it: https://i.stack.imgur.com/m8EFc.jpg