Resume
All Projects

Case Study

LED Control Panel

Arduino Mega 2560 firmware demonstrating interrupt-driven input handling, mode-based state machine, and real-time PWM control from analog input.

Implemented an interactive LED control system on an Arduino Mega 2560 using a push button, potentiometer, and RGB LED to demonstrate foundational embedded firmware concepts. The firmware uses hardware interrupts for deterministic mode switching, a three-mode state machine to define LED behavior, and non-blocking millis()-based timing throughout. Each mode maps potentiometer input to a different output behavior: blink interval control, PWM brightness control, and direct RGB channel intensity mapping.

Role

Embedded Systems Engineer

Timeline

Jan 2025 – Feb 2025

Status

Complete

Platform

Arduino Mega 2560

C++PlatformIOArduinoGPIOPWMInterrupts
LED Control Panel

01

Overview

An Arduino Mega 2560 firmware project demonstrating interrupt-driven input handling, state machine design, and non-blocking execution on a bare-metal MCU. A push button cycles between three operating modes while a potentiometer provides continuous analog input that drives a different LED output behavior in each mode.

02

Technical Design

The main loop reads the flag, applies millis()-based debounce, samples the potentiometer, and dispatches to the active mode handler. Each mode is a standalone function — Mode 0 maps potentiometer value to blink interval, Mode 1 maps it to PWM duty cycle, Mode 2 maps it to the RGB red channel. ADC values are mapped to PWM output using the Arduino map() function.

  • Hardware interrupt for immediate, asynchronous mode switching independent of main loop state.
  • Three-mode state machine: blink interval control, PWM brightness control, and RGB red channel intensity mapping.
  • Non-blocking timing throughout using millis() — no delay() calls in any execution path.

Debounce Without Blocking

Mechanical button bounce caused multiple ISR triggers per physical press, resulting in mode skips. Implementing a millis()-based debounce check in the main loop resolved this while keeping the ISR minimal and fast.

03

Outcomes

  • Mode switching responds immediately to button input at any point in program execution with no missed transitions observed.
  • All three modes produce correct output behavior across the full potentiometer range.
  • Firmware operates entirely non-blocking — no delay() calls in any code path.
  • ISR-to-main communication is reliable across all tested interaction sequences with no observed race conditions.
C++PlatformIOArduino Mega 2560GPIOPWMInterruptsAnalog Inputmillis()

Next Steps

  • Expand to full RGB channel control with independent potentiometer mapping per channel.
  • Add configurable software debouncing with adjustable threshold.
  • Extend mode logic into a more formal FSM with defined transition conditions and entry/exit actions.