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 turned on when the pushbutton is pressed. The pushbutton is configured with an internal pull-up resistor and is connected to ground when pressed. The circuit includes two resistors, one of which is used to limit the current through the LED, and the other's value is not specified (NaN).

Component List

Arduino UNO

Resistor (330 Ohms)

Resistor (Unspecified Value)

LED: Two Pin (green)

Pushbutton

Wiring Details

Arduino UNO

Resistor (330 Ohms)

Resistor (Unspecified Value)

LED: Two Pin (green)

Pushbutton

Documented Code

/*
 * This Arduino sketch controls a green LED with a button.
 * The button uses the internal pull-up resistor and is connected to ground
 * when pressed. When the button is pressed, the LED will turn on.
 */

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

void setup() {
  // Initialize the button pin as an input with internal pull-up resistor
  pinMode(buttonPin, INPUT_PULLUP);
  // Initialize the LED pin as an output
  pinMode(ledPin, OUTPUT);
}

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

The code is written for the Arduino UNO microcontroller. It sets up the button and LED pins, reads the button state, and controls the LED accordingly. The button is configured with an internal pull-up resistor, and the LED is turned on when the button is pressed (when the button state is LOW).