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

Arduino UNO Controlled LED with Pushbutton Interaction

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled LED with Pushbutton Interaction

Circuit Documentation

Summary of the Circuit

This circuit is designed around an Arduino UNO microcontroller and includes a pushbutton, an LED, and two resistors. The purpose of the circuit is to control the state of the LED using the pushbutton. When the button is pressed, the LED turns on; when the button is released, the LED turns off. The Arduino UNO is programmed to read the state of the pushbutton and control the LED accordingly. The resistors are used to limit current to the LED and to provide a pull-up for the pushbutton.

Component List

Arduino UNO

LED: Two Pin (red)

Pushbutton

Resistor (200 Ohms)

Resistor (10k Ohms)

Wiring Details

Arduino UNO

LED: Two Pin (red)

Pushbutton

Resistor (200 Ohms)

Resistor (10k Ohms)

Documented Code

// Code for Arduino UNO
const int ledPin = 2;    // Pin connected to the anode of the LED
const int buttonPin = 3; // Pin connected to the pushbutton

void setup() {
  pinMode(ledPin, OUTPUT);    // Set the LED pin as an output
  pinMode(buttonPin, INPUT);  // Set the button pin as an input
  digitalWrite(buttonPin, HIGH); // Enable the pull-up resistor
}

void loop() {
  int buttonState = digitalRead(buttonPin); // Read the state of the button
  if (buttonState == LOW) {                 // If the button is pressed
    digitalWrite(ledPin, HIGH);             // Turn on the LED
  } else {                                  // If the button is not pressed
    digitalWrite(ledPin, LOW);              // Turn off the LED
  }
}

Filename: sketch.ino

This code sets up the Arduino UNO to control an LED using a pushbutton. The setup() function initializes the LED pin as an output and the button pin as an input with an enabled pull-up resistor. The loop() function continuously checks the state of the button and turns the LED on or off accordingly.