60. LED Patterns Switching

Design a task to switch between the two LED patterns given below using a push button switch. 

Consider the following requirements while implementing the task,

Requirements

  • Button Press Detection: Detect every press, even quick/repeated ones, to switch LED patterns.
  • Debouncing: Handle switch bouncing effectively.
  • Interrupts: Use an Interrupt to detect button presses without disrupting the main loop.
  • LED Patterns: The two LED patterns must be as shown in the GIFs below.

Main Loop Constraint:

The controller is constantly busy executing critical tasks inside the while() loop in the main() 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.
  }
}
 

 

 

Submit Your Solution

Note: Once submitted, your solution goes public, helping others learn from your approach!