I2C Between Arduinos With Potentiometer and LED

Introduction: I2C Between Arduinos With Potentiometer and LED

By Caleb Crockett and Logan Dykes

This circuit is designed to let one board communicate to another. This one is designed to send a value from one to dim or brighten the other LED.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Materials

You will need these items:

1) Breadboard

2) 2 Arduino Uno

3) One LED

4) Potentiometer

5) 220 Ohm resistor

6) Wires

Step 2: Connecting the Breadboards

Connect the two Arduinos with wires going from A4 to A4 and A5 to A5. And also connect the grounds to the grounds. These are analog pins.

Step 3: Connect to LED

Place an Led on the bread board. Make sure you connect the anode to the ground and the cathode to the pin 11. pin 11 has pulse width modulation and can disburse electricity with different pulses. Also. place a resistor between the cathode and the pin 11.

Step 4: Arduino to Potentiometer

First, connect the left pin on the meter to ground and the right pin on the five volt power supply. Next, connect the middle to pin A0.

Step 5: Code for the "Slave Reciever"

// Include the required Wire library for I2C

int LED = 11;

int x = 0;

void setup() {

// Define the LED pin as Output

pinMode (LED, OUTPUT);

// Start the I2C Bus as Slave on address 9


// Attach a function to trigger when something is received.


//bit rate for data transfer over Serial communication



void receiveEvent(int bytes) {

x = Wire.read(); // read one character from the I2C


void loop() {

//potentiometer value from sensor

int ledPWM = map(x, 0, 255, 0, 1023);

analogWrite(LED, ledPWM);

Serial.print("X is: ");


Serial.print("PWM is: ");




Step 6: Code for the "Master Sender"

// Chapter 7 - Communications
// I2C Master // By Cornel Amariei for Packt Publishing

// Include the required Wire library for I2C

#include <wire.h>

int x = 0;

int sensorPin = A0;

int sensorValue = 0;

void setup() {

// Start the I2C Bus as Master




void loop() {

sensorValue = analogRead(sensorPin);



// transmit to device #9




// stop transmitting


Step 7: End Result

Now both of the Arduinos should be connected and ech should be hooked up with the LED and the other to the potentiometer. Make sure you have the right code uploaded to each. The slave is the LED and the Master is the meter.

Be the First to Share


    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest



    2 years ago

    Thanks for sharing :) Do you have any photos of the completed project?