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

Arduino UNO Controlled LED with Pushbutton

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

Circuit Documentation

Summary of the Circuit

This circuit is designed to control an LED using an Arduino UNO microcontroller in response to the state of a pushbutton. When the button is pressed, the LED turns off; when the button is not pressed, the LED remains on. The circuit includes two resistors, one to limit the current to the LED and another as a pull-down for the pushbutton. The Arduino UNO is programmed to read the state of the pushbutton and control the LED accordingly.

Component List

Resistor (1 kOhms)

Resistor (200 Ohms)

LED: Two Pin (red)

Pushbutton

Arduino UNO

Wiring Details

Resistor (1 kOhms)

Resistor (200 Ohms)

LED: Two Pin (red)

Pushbutton

Arduino UNO

Documented Code

// Code for controlling an LED with a pushbutton using Arduino UNO
const int LED = 9;      // LED connected to digital pin 9
const int BUTTON = 2;   // Pushbutton connected to digital pin 2

void setup() {
  pinMode(LED, OUTPUT);    // Set the LED pin as an output
  pinMode(BUTTON, INPUT);  // Set the pushbutton pin as an input
}

void loop() {
  // Read the state of the pushbutton
  if (digitalRead(BUTTON) == LOW) {
    // If the button is pressed, turn off the LED
    digitalWrite(LED, LOW);
  } else {
    // If the button is not pressed, turn on the LED
    digitalWrite(LED, HIGH);
  }
}