Nuvoton MG51FB9AE LED Control Firmware

Job ID: 39784582

Budget: ₹1,500 – ₹12,500 INR

I have a Nuvoton MG51FB9AE board fitted with four momentary-push buttons (1-4) and three output LEDs (A-C). I need a small but tidy C++ firmware that maps the inputs to the outputs as follows:

• Button 1 → LED A on
• Button 2 → LED B on
• Button 3 → LED C on
• Button 4 → all LEDs off

Only one LED may remain lit at any time; pressing another numbered button must switch the active LED accordingly.

Lock mode
Pressing Button 1 again while any LED is already on must place the board in a lock state where ALL three LEDs stay continuously on. The unit must also lock automatically after a user-defined timeout (default 2 minutes; range up to 4 000 hours, stored in flash or EEPROM so it survives power loss). In lock mode the buttons no longer change the LEDs, they only participate in the unlock sequence.

Unlocking
Exit from lock mode requires a user-definable four-button pattern. The sequence must be compared exactly; a wrong key breaks the attempt and leaves the unit locked.

What I need from you
• Complete, well-commented C++ source targeting the MG51FB9AE, compilable in Keil or a comparable toolchain.
• Pin and peripheral initialisation matching the default evaluation board (I will supply the exact schematic once we start).
• Non-volatile storage of the timeout value and unlock pattern.
• Debounce handling for the mechanical keys.
• A concise README that explains the memory map, build steps, and how to change the timeout or pattern.

Acceptance will be based on flashing the hex file to my board, observing correct LED behaviour in normal operation, reliable entry into lock mode by either trigger, and a successful unlock only when the precise pattern is entered.