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

Arduino Nano Controlled Pushbutton LED Circuit

View and Edit Project In Cirkit DesignerImage of Arduino Nano Controlled Pushbutton LED Circuit

Circuit Documentation

Summary of the Circuit

This circuit is designed to control an LED using a pushbutton. When the pushbutton is pressed, the LED lights up, and when the pushbutton is released, the LED turns off. The circuit utilizes an Arduino Nano as the microcontroller to read the state of the pushbutton and control the LED accordingly. The LED is connected through a resistor to limit the current, and there is also a pull-down resistor connected to the pushbutton to ensure a stable LOW signal when the button is not pressed.

Component List

Arduino Nano

Pushbutton

Resistor (10k Ohms)

Resistor (200 Ohms)

LED: Two Pin (red)

Wiring Details

Arduino Nano

Pushbutton

Resistor (10k Ohms)

Resistor (200 Ohms)

LED: Two Pin (red)

Documented Code

/*
 * This Arduino sketch controls an LED using a pushbutton. 
 * When the pushbutton is pressed, the LED will light up. 
 * When the pushbutton is released, the LED will turn off.
 */

const int buttonPin = 2; // Pin connected to the pushbutton
const int ledPin = 3;    // Pin connected to the LED through a resistor

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

void loop() {
  // Read the state of the pushbutton value:
  int buttonState = digitalRead(buttonPin);
  // Check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // Turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // Turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

This code is written for the Arduino Nano and is saved as a .ino file. It sets up the necessary input and output pins and contains a loop that continuously checks the state of the pushbutton. When the button is pressed, the LED is turned on; when it is released, the LED is turned off.