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

Arduino UNO R4 WiFi Dual Pushbutton LED Control System

View and Edit Project In Cirkit DesignerImage of Arduino UNO R4 WiFi Dual Pushbutton LED Control System

Circuit Documentation

Summary

The circuit in question is designed around two Arduino UNO R4 WiFi microcontrollers, which are interconnected and control two red LEDs through pushbuttons. The LEDs are connected with resistors to limit the current and protect the LEDs. The pushbuttons are used to toggle the state of the LEDs and send a signal to the microcontrollers. The microcontrollers communicate with each other via serial communication, and the state of the LEDs can be changed through this communication as well.

Component List

Microcontrollers

LEDs

Pushbuttons

Resistors

Wiring Details

Arduino UNO R4 WiFi

LED: Two Pin (red)

Pushbutton

Resistor

Documented Code

Arduino UNO R4 WiFi (First Microcontroller)

unsigned long prev = 0; 
const int LED = 10; 
const int button = 8;  
int ledOn = HIGH;         
bool buttonPressed = false;  

void setup() {
    pinMode(LED, OUTPUT);
    pinMode(button, INPUT_PULLUP); 
    digitalWrite(LED, ledOn);
    Serial.begin(9600);
}

void loop() {
    if (digitalRead(button) == LOW && !buttonPressed) {
        unsigned long curr = millis();
        if (curr - prev > 100) {
            buttonPressed = true; 
            prev = curr; 
            Serial.write('L'); 
        }
    }
    else if (digitalRead(button) == HIGH && buttonPressed) {
        buttonPressed = false; // Reset button state
    }

    if (Serial.available() > 0) {
        Serial.read(); 
        ledOn = !ledOn; // Toggle LED
        digitalWrite(LED, ledOn); // Update LED
    }
}

Arduino UNO R4 WiFi (Second Microcontroller)

unsigned long prev = 0; 
const int LED = 10; 
const int button = 8;  
int ledOn = HIGH;         
bool buttonPressed = false;  

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(button, INPUT_PULLUP); 
  digitalWrite(LED, ledOn);
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(button) == LOW && !buttonPressed) {
    unsigned long curr = millis();
    if (curr - prev > 100) {
      buttonPressed = true; 
      prev = curr; 
      Serial.write('L'); 
    }
  }
  else if (digitalRead(button) == HIGH && buttonPressed) {
    buttonPressed = false; // Reset button state
  }

  if (Serial.available() > 0) {
    Serial.read(); 
    ledOn = !ledOn; // Toggle LED
    digitalWrite(LED, ledOn); // Update LED
  }
}

This concludes the documentation for the provided circuit design. The code for both microcontrollers is identical and is designed to toggle the state of an LED when a button is pressed and also when a signal is received via serial communication.