Button-Controlled LED Using Arduino
Button-Controlled LED Using Arduino
Networking 1
Partial Requirements
Date:
06/11/2024
Submitted by:
ARIAN RAM SALEM
BSIT - 2B
Submitted to:
MR. JOSIE DEGORIO
Project Title:
Button-Controlled LED Using Arduino
Description:
This circuit connects a microcontroller to an LED and a pushbutton, allowing the LED
to toggle on and off with each button press. The LED's anode is connected to pin 13 on the
microcontroller, with a current-limiting resistor connecting the cathode to ground. The
pushbutton is connected to pin 2, configured with an internal pull-up resistor to keep the
input high when the button is unpressed and low when pressed. This setup enables the
microcontroller to detect each button press and toggle the LED accordingly. The
microcontroller is powered via USB or an external 5V source.
BILL OF MATERIALS:
SCHEMATIC:
CODES:
void setup() {
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == pressed){
while(buttonState == pressed)
{
buttonState = digitalRead(buttonPin);
delay(55);
}
static boolean output = HIGH;
output = !output;
if (output == LOW){
digitalWrite(ledPin,HIGH);
Serial.println("ON");
}
else{
digitalWrite(ledPin,LOW);
Serial.println("OFF");
}
SUMMARY:
This project creates a simple LED toggle switch using a microcontroller, an LED, and
a pushbutton. The LED is connected to a digital output pin, while the pushbutton is
connected to an input pin with an internal pull-up resistor. Each button press toggles the LED
between on and off states, demonstrating basic digital input and output control with the
microcontroller.