Challenge

Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol

ABINAYA MAM 

I2C Communication Protocol

I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol incorporated into devices for serial communication. It was originally designed by Philips Semiconductor in 1982. Recently, it is a widely used protocol for short-distance communication. It is also known as Two Wired Interface(TWI).

Working of I2C Communication Protocol :
It uses only 2 bi-directional open-drain lines for data communication called SDA and SCL. Both these lines are pulled high.

Serial Data (SDA) – Transfer of data takes place through this pin.
Serial Clock (SCL) – It carries the clock signal.

I2C operates in 2 modes –

 

·       Master mode

·       Slave mode

Each data bit transferred on SDA line is synchronized by a high to the low pulse of each clock on the SCL line.

According to I2C protocols, the dat line can not change when the clock line is high, it can change only when the clock line is low. The 2 lines are open drain, hence a pull-up resistor is required so that the lines are high since the devices on the I2C bus are active low. The data is transmitted in the form of packets which comprises 9 bits. The sequence of these bits are –

1.     Start Condition – 1 bit

2.     Slave Address – 8 bit

3.     Acknowledge – 1 bit

Advantages :

·       Can be configured in multi-master mode.

·       Complexity is reduced because it uses only 2 bi-directional lines (unlike SPI Communication).

·       Cost-efficient.

·       It uses ACK/NACK feature due to which it has improved error handling capabilities.

Limitations :

·       Slower speed.

 

·       Half-duplex communication is used in the I2C communication protocol.

 

PROGRAM

#include

#include

LiquidCrystal display(12, 11, 5, 4, 3, 2);

void setup()

{

  display.begin(16, 2); 

  display.print("Hai slave");

  Wire.begin();

  Wire.requestFrom(2,10);

  Serial.begin(9600);

}

void loop()

{

  display.setCursor(0, 1);

  //display.clear();

  //delay(1000);

  while(Wire.available())

  {

    char c=Wire.read();

    display.print(c);

    Serial.print(c); 

  }

  }

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.