Circuit Documentation
Summary of the Circuit
This circuit is designed around an Arduino UNO microcontroller and includes a pushbutton, an LED, and two resistors. The purpose of the circuit is to control the state of the LED using the pushbutton. When the button is pressed, the LED turns on; when the button is released, the LED turns off. The Arduino UNO is programmed to read the state of the pushbutton and control the LED accordingly. The resistors are used to limit current to the LED and to provide a pull-up for the pushbutton.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
LED: Two Pin (red)
- Description: A red light-emitting diode.
- Pins: cathode, anode
Pushbutton
- Description: A simple push-to-make button.
- Pins: Pin 1 (in), Pin 2 (in), Pin 3 (out), Pin 4 (out)
Resistor (200 Ohms)
- Description: A resistor with a resistance of 200 Ohms.
- Pins: pin1, pin2
Resistor (10k Ohms)
- Description: A resistor with a resistance of 10k Ohms.
- Pins: pin1, pin2
Wiring Details
Arduino UNO
- 5V: Connected to the 10k Ohm resistor (pin1)
- GND: Connected to the pushbutton (Pin 1 (in)) and the 200 Ohm resistor (pin1)
- D3: Connected to the pushbutton (Pin 4 (out)) and the 10k Ohm resistor (pin2)
- D2: Connected to the anode of the LED
LED: Two Pin (red)
- Anode: Connected to Arduino UNO (D2)
- Cathode: Connected to the 200 Ohm resistor (pin2)
Pushbutton
- Pin 1 (in): Connected to Arduino UNO (GND)
- Pin 4 (out): Connected to Arduino UNO (D3) and the 10k Ohm resistor (pin2)
Resistor (200 Ohms)
- Pin1: Connected to Arduino UNO (GND)
- Pin2: Connected to the cathode of the LED
Resistor (10k Ohms)
- Pin1: Connected to Arduino UNO (5V)
- Pin2: Connected to the pushbutton (Pin 4 (out)) and Arduino UNO (D3)
Documented Code
// Code for Arduino UNO
const int ledPin = 2; // Pin connected to the anode of the LED
const int buttonPin = 3; // Pin connected to the pushbutton
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
pinMode(buttonPin, INPUT); // Set the button pin as an input
digitalWrite(buttonPin, HIGH); // Enable the pull-up resistor
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the state of the button
if (buttonState == LOW) { // If the button is pressed
digitalWrite(ledPin, HIGH); // Turn on the LED
} else { // If the button is not pressed
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
Filename: sketch.ino
This code sets up the Arduino UNO to control an LED using a pushbutton. The setup() function initializes the LED pin as an output and the button pin as an input with an enabled pull-up resistor. The loop() function continuously checks the state of the button and turns the LED on or off accordingly.
