Go Down

Topic: basic read code, I think it works (Read 759 times) previous topic - next topic

This seems to give me some results with a scavenged Amtel 24C04, pins 1,2,3 & 4 to Gnd, 8 to Vcc(+5v), 7 to Gnd*, 5 (SDA) & 6 (SCL) to pin 2(SDA) & 3(SCL) respectively, on an Arduino Micro, on a breadboard with a 5v IC (KIA7805PI) powered by a 9v Battery

On the 24C04, pins 1,2,3 are A0, A1, A2, to set the address (7bit, starting at 0x50), 4 Gnd, 5 Sda, 6 Scl, 7 is tied to Gnd for write (or Vcc (+5v) for write-protect) and 8 is Vcc (+5v)

The Arduino Gnd & VI (Voltage Input / Reference) are connects to the 7805 Gnd and +5v pins respectively.

This might be some help  http://www.arduino.cc/playground/Code/I2CEEPROM

I need to do a write then read it to see if it's really working correctly... if anyone sees anything wrong let me know.


Quote


#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop()
{
  Wire.requestFrom(0x50, 1);    // request 6 bytes from slave device #2

  while(Wire.available())    // slave may send less than requested
  {
    char c = Wire.read();    // receive a byte as character
    Serial.print(c);         // print the character
  }

  delay(500);
}


Erdin

The code does not write.
And I think you should write the address (the register address inside the EEPROM) first, before you can start reading.
You request 1 byte, and in the comment it says 6 bytes.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy