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 a green LED using an Arduino UNO microcontroller and a pushbutton. The LED is connected to the Arduino with a series resistor to limit the current. The pushbutton is used to toggle the state of the LED; when the button is pressed, the LED turns on, and when the button is released, the LED turns off. The button utilizes a pull-down resistor to ensure a clear LOW signal when it is not pressed.

Component List

Arduino UNO

LED: Two Pin (green)

Pushbutton

Resistor (Unspecified Value)

Resistor (330 Ohms)

Wiring Details

Arduino UNO

LED: Two Pin (green)

Pushbutton

Resistor (Unspecified Value)

Resistor (330 Ohms)

Documented Code

/*
 * This Arduino sketch controls a green LED using a button with a pull-down
 * resistor configuration. When the button is pressed, the LED will turn on.
 * When the button is released, the LED will turn off.
 */

const int buttonPin = 2; // Pin connected to the button
const int ledPin = 13;   // Pin connected to the green LED

void setup() {
  pinMode(buttonPin, INPUT); // Set button pin as input
  pinMode(ledPin, OUTPUT);   // Set LED pin as output
}

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