ATMEGA168/Arduino with a 24LC08 Serial EEPROM
Basic Schematic. R1, R2 are 10,000 ohms.

Arduino Interfacing and Programming 24LC08 Serial EEPROM

by Lewis Loflin

Explanation of program:

On power up or reset the "setup" is executed once, setting up the hardware and writing the text message "Arduino" to the EEPROM. Then the "loop" section will run over and over. Whenever sw0 is pressed the text message "Arduino" is read from the EEPROM and sent via the serial port to a computer running for example Hyper Terminal. This demonstrates the use of the Wire.h library, serial ports, and an external switch tied to an input.

For the basic structure of an Arduino program see page 7 of Arduino Programming Notebook by Brian Evans

For information on setting up switches and pull ups on the Arduino see pages 4-6 on Arduino Projects by Tod Kurt

Basic I2C connections
Basic I2C setup.

24LC08 Demo with the ATMEGA128
This is an 8-pin DIP serial EEPROM. It will store 1024 bytes. (0x3FF)
It uses I2C or "two wire" interface.
See 24LC08 Serial EEPROM

Pin designations for the 24LC08:
Pins 1, 2, 3 if tied to VCC (5 volts) address = 0x54. If tied to VSS 0x50. Only two can be used in a single circuit.
Pin 4 VSS or ground.
Pin 5 SDA or serial data. Tied to Arduino analog pin 4.
Pin 6 SCL or serial clock. Tied to Arduino analog pin 5.
Pin 7 WP or write protect. VCC disables write, VSS enables write.
Pin 8 VCC or +5 volts.

#include <Wire.h> // specify use of Wire.h library.

byte sw0 = 12; // digital pin for switch connected to ground.

// address in 24LC08. values from 000 hex to 3FF hex. 

int position_pointer = 0x3f0; 

void setup() 
  pinMode(sw0, INPUT);
  digitalWrite(sw0, HIGH); // turn on internal pull up
  Wire.begin(); // join i2c bus (address optional for master) 
  Serial.begin(9600);  // setup serial for output 
  // send test message "Arduino"
  Wire.beginTransmission(0x50); // connect to 24LC08 device address 
  Wire.send(position_pointer); // beginning address within EEPROM


void loop() 
  while (digitalRead(sw0) == 1) { 
  } // wait here until switch is pushed.
  Wire.beginTransmission(0x50); // link to 24LC08
  Wire.send(position_pointer); // must act as a position pointer
  Wire.requestFrom(0x50, 7); 
// request 7 bytes from slave device 24LC08

  // below will loop until 7 bytes are received. 

  while(Wire.available()) // slave may send less than requested 
    byte c = Wire.receive(); // receive a byte as character 
    Serial.print(c); // print the character 
  Serial.print("\n"); // next line
  delay(1000); // wait one second. 

Added September 20, 2013:

Added June 7, 2013:

You Tube Arduino Microcontroller Video Series March 2012:

Arduino demos: