This project implements an LED Intensity Controller using a microcontroller (PIC24F16KA101) and Python.
The system allows users to:
- Control the brightness of LEDs using a potentiometer.
- Blink LEDs at adjustable intensity.
- Log LED intensity and ADC readings to a PC via UART.
- Visualize the data in real-time or after logging.
The project uses a Finite State Machine (FSM) architecture and Pulse Width Modulation (PWM) to control LED brightness.
| Input | Action |
|---|---|
| PB1 Click | Toggle system ON: LED1 turns on, brightness controlled via potentiometer. |
| PB1 Long Press (ON mode) | Swap LEDs: LED1 off & LED2 on, brightness controlled via potentiometer. Another long press swaps back. |
| PB1 Click (ON mode) | Enter OFF mode: LEDs off, low-power Idle mode. |
| PB2 Click (ON mode) | Blink active LED at 500 ms intervals. Brightness during blink follows potentiometer value. |
| PB2 Click (OFF mode) | Blink LED at 100% intensity at 500 ms intervals. Blinking stops on subsequent PB2 click. |
| PB3 Click (ON mode) | Start UART transmission of LED intensity & ADC readings to PC for 1 minute. Clicking PB3 again stops transmission. |
- Duty cycle of PWM controls LED brightness (0–100%).
- PWM frequency chosen to avoid visible flicker while minimizing power consumption.
- Data transmitted at >2 Hz to capture blink accurately.
- Python script stores readings in a CSV file named after the group.
- After 1 minute, generates plots:
- LED intensity vs. time
- ADC reading vs. time
- Finite State Machine (FSM) architecture.
- LED brightness controlled via software PWM, without using dedicated PWM peripherals.
- Timer peripherals used for PWM timing and blink intervals.
- Button debouncing and long-press detection implemented in software.
- UART communication implemented safely (no function calls in ISR unless reentrant).
- Efficient interrupt handling; no polling of input ports.
- Reads UART data from microcontroller.
- Stores intensity and ADC readings in CSV (
<group_name>_data.csv). - Generates plots using Matplotlib.