This project demonstrates how to use an External Interrupt (EXTI) to control an LED using a push button on the STM32F446RE Nucleo board.
- When the user button (PC13) is pressed, it triggers an EXTI interrupt.
- Inside the interrupt handler, the LED (PA5) toggles its state.
- The LED remains in its toggled state until the next button press.
- The project is developed using STM32CubeIDE and HAL libraries.
| Pin | Function | Description |
|---|---|---|
| PC13 | Input | User button (EXTI) |
| PA5 | Output | LED (active HIGH) |
| File | Description |
|---|---|
| main.c | Initializes GPIO and configures EXTI |
| stm32f4xx_it.c | Handles the interrupt (toggles LED) |
| main.h | Header file for main source |
| stm32f4xx_it.h | Interrupt declarations |
| STM32_Button_LED_Interrupt.ioc | Pin & clock configuration file |
- Open the project in STM32CubeIDE.
- Connect your Nucleo STM32F446RE board.
- Build → Debug → Run.
- Press the blue USER button → observe LED toggle (PA5).
This project follows the STMicroelectronics software license included in the LICENSE file.
You can add software debounce by adding a small delay inside the interrupt handler, or better — use a timer-based debounce to make it more reliable.