I2C Between Arduinos With Potentiometer and LED: by Crockettcaleb
I2C Between Arduinos With Potentiometer and LED: by Crockettcaleb
I2C Between Arduinos With Potentiometer and LED: by Crockettcaleb
by crockettcaleb
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.
1) Breadboard
2) 2 Arduino Uno
3) One LED
4) Potentiometer
6) Wires
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.
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.
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.
// Include the required Wire library for I2C void receiveEvent(int bytes) {
#include
x = Wire.read(); // read one character from the I2C
int LED = 11;
}
int x = 0;
void loop() {
void setup() {
//potentiometer value from sensor
// Define the LED pin as Output
int ledPWM = map(x, 0, 255, 0, 1023);
pinMode (LED, OUTPUT);
analogWrite(LED, ledPWM);
// Start the I2C Bus as Slave on address 9
Serial.print("X is: ");
Wire.begin(9);
Serial.println(x);
// Attach a function to trigger when something is
received. Serial.print("PWM is: ");
Wire.onReceive(receiveEvent); Serial.println(ledPWM);
Serial.begin(9600); }
int x = 0; Serial.println(sensorValue);
Wire.begin(); Wire.endTransmission();
// stop transmitting
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.