0% found this document useful (0 votes)
4 views

Button-Controlled LED Using Arduino

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Button-Controlled LED Using Arduino

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Data Communication and

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:

Item Parts Name Quantity Cost Each Cost


Number (PHP) Extended
(PHP)
1 Arduino Uno 1 1000 1000
Board
2 LED 1 15 15
3 Pushbutton 1 200 200
4 Jumper Wire 6 5 28
Total number of parts: 9 Total costs: 1,243

SCHEMATIC:
CODES:

const int buttonPin = 2; // the number of the pushbutton pin


const int ledPin = 13; // the number of the LED pin
int buttonState = 0; // variable for reading the pushbutton
status
boolean pressed = false;

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.

You might also like