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
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central controller for the circuit, reading the button state and controlling the LED.
LED: Two Pin (green)
- Description: A basic green light-emitting diode.
- Purpose: Emits light when powered, indicating the button press.
Pushbutton
- Description: A simple push-to-make button.
- Purpose: Allows the user to input a signal to the Arduino, controlling the LED state.
Resistor (Unspecified Value)
- Description: A resistor with an unspecified resistance value.
- Purpose: Intended to be used as a pull-down resistor for the pushbutton but lacks a specified value.
Resistor (330 Ohms)
- Description: A resistor with a resistance of 330 Ohms.
- Purpose: Limits the current flowing through the LED to prevent damage.
Wiring Details
Arduino UNO
- GND connected to the cathode of the LED and one pin of the unspecified resistor.
- D13 connected to one pin of the 330 Ohm resistor.
- D2 connected to one pin of the pushbutton and one pin of the unspecified resistor.
- 5V connected to the other pin of the pushbutton.
LED: Two Pin (green)
- Cathode connected to GND on the Arduino UNO.
- Anode connected to one pin of the 330 Ohm resistor.
Pushbutton
- Pin 2 (in) connected to D2 on the Arduino UNO and one pin of the unspecified resistor.
- Pin 4 (out) connected to 5V on the Arduino UNO.
Resistor (Unspecified Value)
- Pin1 connected to D2 on the Arduino UNO.
- Pin2 connected to GND on the Arduino UNO and the cathode of the LED.
Resistor (330 Ohms)
- Pin1 connected to D13 on the Arduino UNO.
- Pin2 connected to the anode of the LED.
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
}
}
- File Name: sketch.ino
- Description: The code sets up the Arduino UNO to read the state of a pushbutton and control an LED accordingly. The
buttonPinis configured as an input, and theledPinis configured as an output. In theloopfunction, the state of the button is read, and the LED is turned on or off based on this state.
