Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Pushbutton-Controlled LED System with I2C Communication

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Pushbutton-Controlled LED System with I2C Communication

Circuit Documentation

Summary

This circuit involves two Arduino Nano microcontrollers, a pushbutton, two resistors, and a red LED. The circuit is designed to read the state of a pushbutton and transmit this state to another Arduino Nano, which then controls an LED based on the received state.

Component List

  1. Arduino Nano

    • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.
    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
  2. Pushbutton

    • Description: A simple pushbutton switch.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
  3. Resistor (10k Ohms)

    • Description: A resistor with a resistance of 10k Ohms.
    • Pins: pin1, pin2
  4. LED: Two Pin (red)

    • Description: A red LED with two pins.
    • Pins: cathode, anode
  5. Resistor (330 Ohms)

    • Description: A resistor with a resistance of 330 Ohms.
    • Pins: pin1, pin2

Wiring Details

Arduino Nano (1)

Arduino Nano (2)

Pushbutton

Resistor (10k Ohms)

Resistor (330 Ohms)

LED: Two Pin (red)

Code Documentation

Arduino Nano (1) Code

#include <Wire.h>
int pushButton = A0;
int x = 0;

void setup() {
  Wire.begin();
  pinMode(pushButton, INPUT);
}

void loop() {
  Wire.beginTransmission(1);
  x = digitalRead(pushButton);
  Wire.write(x);
  Wire.endTransmission();
  delay(500);
}

Arduino Nano (2) Code

#include <Wire.h>
int pinLed = 13;
int x = 0;

void setup() {
  Wire.begin(1);
  Wire.onReceive(receiveEvent);
  pinMode(pinLed, OUTPUT);
}

void loop() {
  delay(100);
}

void receiveEvent(int howMany) {
  x = Wire.read();
  if (x == 1) {
    digitalWrite(pinLed, HIGH);
  } else {
    digitalWrite(pinLed, LOW);
  }
}