Circuit Documentation
Summary
This circuit consists of an Arduino UNO microcontroller, a pushbutton, and a red LED. The pushbutton is used to control the LED. When the pushbutton is pressed, the LED turns on; otherwise, the LED remains off.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Pushbutton
- Description: A simple pushbutton switch.
- Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)
LED: Two Pin (red)
- Description: A red LED with two pins.
- Pins: cathode, anode
Wiring Details
Arduino UNO
- D13: Connected to the cathode of the LED.
- GND: Connected to the anode of the LED.
- D2: Connected to Pin 1 (in) and Pin 2 (in) of the pushbutton.
- GND: Connected to Pin 1 (in) and Pin 2 (in) of the pushbutton.
Pushbutton
- Pin 1 (in): Connected to D2 and GND of the Arduino UNO.
- Pin 2 (in): Connected to D2 and GND of the Arduino UNO.
- Pin 3 (out): Connected to Pin 4 (out) of the pushbutton.
- Pin 4 (out): Connected to Pin 3 (out) of the pushbutton.
LED: Two Pin (red)
- cathode: Connected to D13 of the Arduino UNO.
- anode: Connected to GND of the Arduino UNO.
Code Documentation
Arduino UNO Code
// Pin assignments
const int buttonPin = 2; // Push button connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13
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 push button
if (buttonState == HIGH) { // If button is pressed
digitalWrite(ledPin, HIGH); // Turn ON the LED
} else {
digitalWrite(ledPin, LOW); // Turn OFF the LED
}
}
This code sets up the Arduino UNO to read the state of the pushbutton and control the LED accordingly. The buttonPin is configured as an input, and the ledPin is configured as an output. In the loop function, the state of the pushbutton is read, and the LED is turned on or off based on whether the button is pressed.
