Push Button and LED with LPC1768 | Control LED with push button | Control LED from Switch

Опубликовано: 24 Март 2026
на канале: Know about Embedded System
151
9

To control an LED with a push button using the NXP LPC1768 microcontroller, you need to configure specific General Purpose Input/Output (GPIO) pins: one as an output for the LED and one as an input for the button.

Hardware Setup
A common configuration uses internal pull-up resistors for the button and a current-limiting resistor for the LED.

LED Connection: Connect the LED anode to a GPIO pin (e.g., P1.29) through a 330Ω resistor and the cathode to GND.
Button Connection: Connect one side of the push button to a GPIO pin (e.g., P1.28) and the other side to GND. When pressed, the pin reads LOW (0); when released, it reads HIGH (1) due to the pull-up

GPIO Register Configuration
The LPC1768 uses "Fast I/O" (FIO) registers for high-speed bit manipulation:

FIODIR: Sets pin direction. 1 for Output (LED), 0 for Input (Button).

FIOPIN: Reads the current status of the pins.

FIOSET / FIOCLR: Sets a pin HIGH (ON) or LOW (OFF)

Header File: Always include lpc17xx.h to access the register structures like LPC_GPIO1.

Pin Selection: Note that not all pins on every port are available for use; for example, on Port 1, pins 2, 3, 7, 6, 5, 11, 12, and 13 are reserved.

Debouncing: Mechanical buttons often "bounce," causing multiple triggers. For complex logic like toggling a state with one press, you may need a small delay

Chapters:-
00:00 Introduction
00:43 Control the output using switch
02:15 Programming tutorial one condition
05:09 Output validation one condition
06:52 Control the output with TWO different conditions
07:49 Programming tutorial for two conditions
09:00 Output validation for two conditions
10:32 Control the output with THREE different conditions
11:14 Programming tutorial for three conditions
12:40 Output validation for three conditions



If you have any questions please write to us
email : [email protected]

-----------------------------------------------------------------------------------------------------------------------------------------
Your questions:-
GPIO Programming
GPIO Programming Raspberry pi
GPIO Programming in C
GPIO Programming in Embedded C
STM32 GPIO Programming
GPIO Configuration
GPIO Projects
Programming GPIO Raspberry pi in python
Raspberry pi GPIO Programming in C
GPIO Programming in Python
ESP32 GPIO Programming
Programming GPIO Pins
GPIO Programming in 8051
GPIO Programming in PIC
GPIO Programming in MSP
GPIO Programming in LPC2129
what is a GPIO used for
what programming language use for GPIO
which python library is used for GPIO
Does Arduino use GPIO

-------------------------------------------------------------------------------------------------------------------------------------------------

Don’t forget to Like, Share, and Subscribe for more tutorials on Embedded Systems and Microcontrollers.

#PushButton
#led
#EmbeddedSystems
#microcontrollerprogramming
#ButtonControl
#ledcontrol