Thursday, 2 August 2012

Connecting two Arduinos using I2C interface

What happen if you have a project with inputs and outputs more than your microcontroller can handle ?
you can buy another microcontroller with larger input / output pins ( and this is a solution i don't advise you to use as it will be expensive and hard to solder it in your board) or you can use two smaller (less number of inputs /outputs) microcontrollers and connect them together to sent data or commands to each other and this is the solution we are going to discuss in this post.

In this post we are going to connect two arduino boards using I2C .

I2C - I2C Requires Analog Pins 4 and 5 and two pull-up resistors. You can connect more than 100 Arduino's on the same 2 pins. It's simple, reliable and easy-to-use.

Master and Slave in I2C :

The I2C protocol defines the concept of master and slave devices. A master device is the device that is in charge of the bus. This device controls the clock and generates the START and STOP signals. Slave devices listen to the commands sent by the Master and respond to them.


The two analog pins 4 and 5 of the two boards are connected with each other and they are pulled up to Vcc using pull up resistor of values between 1.5K to 47K.

NOTE : The two boards must have the same Vcc and GND.

The connection is shown in the following figure :


 We need to include the Wire library. This contains all the commands we need for using I2C.

For the Master:
Simply use Wire.begin() to start the I2C Bus on this Arduino as a Master.

For the Slave:
Use Wire.begin(address) to start the I2C Bus as a Slave. 

In the master program :
The master sends 0 and then after a delay of two seconds it sends 1 .

In the slave program :
The slave has address 5 and if the data sent was zero it will blink LED_1 and if the data sent was one it will blink LED_2 .

you can download the master and the slave programs and the simulation file using proteus from the following link :
I2C programs and simulation using proteus

Download this tutorial in PDF HERE
If you want to learn how to simulate arduino sketches using proteus click here

Do you like this post? Please link back to this article by copying one of the codes below.

URL: HTML link code: BB (forum) link code:


  1. Hi there,

    What version of Proteus are you using?

    Would you be able to save the simulation files in an older version like 7.4


  2. I use version 7.9 SP1 you can download it from the internet search for google