Build a task using a microcontroller to detect single, double, and long presses of the push button switch with the following requirements:
- Push Button Press Actions
- Single press → toggle LED 1
- Double press → toggle LED 2
- Long press → turn OFF both LEDs. (more than 1 second)
- Button Debouncing: Implement debouncing to prevent multiple detections from a single push button switch press.
Main Loop Constraint:
The controller is constantly busy executing critical tasks inside the while() loop in the main function, as shown in the code below, so use Interrupts to implement tasks.
main () {
while (true) {
//In this loop Microcontroller is busy in monitoring and performing critical tasks constantly.
}
}