A flexible Arduino-based light control system with native pulsing support, pattern compression, automatic calibration management, precise timing control, and pulse frequency modulation.
Version: 2.2.2
Last Updated: December 12, 2025
Status: Production Ready β
- What's New in v2.2 - Latest features including automatic calibration
- Quick Start - Get running in 10 minutes
- Key Features - What it can do
- Examples - Ready-to-use protocols (automatic vs preset calibration)
- Documentation Index - 50+ organized guides
- Protocol File Format - Syntax reference
- Project Structure - File organization
- Need Help? - Support resources
- π€ Board identification - Unique ID per Arduino (serial number/VID:PID)
- πΎ Database storage - Calibrations saved to
calibration_database.json - β»οΈ Auto-retrieval - Stored calibrations automatically loaded
- β° 3-month expiration - Auto-recalibration every 90 days for accuracy
- π§ Multi-board support - Different calibrations for different boards
- π Database management - View, export, delete calibrations
Why 3 months? Crystal oscillators drift Β±1-5 ppm/year. Over 3 months, this accumulates to 0.25-1.25 ppm drift, potentially causing 1-4 seconds error over 12-hour protocols. Regular recalibration ensures <1 second timing accuracy.
π Automatic Calibration Guide - Complete system documentation
π Backward Compatibility - How old protocols still work
- Automatic pattern detection - Reduces hundreds of commands to just a few
- Compression ratios up to 37:1 - 97%+ reduction in transmitted data
- pattern_length parameter - Optimize for 2-element (default) or 4-element patterns
- Efficiency analysis - System recommends optimal pattern_length
π Pattern Compression Guide - Complete compression details
- Arduino compatibility checking - Prevents pattern_length mismatches
- Early error detection - Catches issues before execution
- Clear error messages - Tells you exactly how to fix problems
- Class-based design -
LightControllerParserclass for reusability - 70% smaller entry point -
protocol_parser.pynow just 49 lines - Command preview - Test protocols without hardware
π Refactoring Guide - Architecture details
# Clone repository
git clone https://github.com/Swida-Alba/light_controller_v2.git
cd light_controller_v2.2
# Install Python dependencies
pip install -r requirements.txtπ Full Installation Guide - Detailed setup instructions
- Open
light_controller_v2_2_arduino/light_controller_v2_2_arduino.inoin Arduino IDE - Configure settings (if needed):
const int PATTERN_LENGTH = 2; // 2, 4, 8, etc. (must match Python) #define PULSE_MODE_COMPILE 1 // 1=Enable pulses, 0=Disable (saves ~2.5KB)
- Select your board: Tools β Board β Arduino Uno/Due/Mega
- Select port: Tools β Port β (your Arduino port)
- Click Upload
π Arduino Setup Guide - Board-specific instructions
π Firmware Update Guide - Updating existing firmware
Option A: Try Automatic Calibration (Recommended)
python protocol_parser.py 2 /dev/cu.usbmodem14301 examples/auto_calibration/simple_blink_example.txtFirst time:
Identifying Arduino board...
Board ID: 0852420f343bb48d
No calibration found. Calibrate now? (Y/n): y
[Calibration proceeds for ~5 minutes]
β Calibration saved: 1.025847
Future runs:
β Found calibration: 1.025847
Age: 15 days (0.5 months) - Valid β
[Uses stored calibration automatically]
Option B: Use Preset Calibration (Legacy)
python protocol_parser.py 2 /dev/cu.usbmodem14301 examples/preset_calibration/simple_blink_example.txtShows warning about manual CALIBRATION_FACTOR, but still works!
π Usage Guide - Complete usage instructions
π Examples Guide - All example protocols explained
After execution starts, an interactive HTML visualization automatically opens showing:
- π΄ Real-time status updates every second
- π‘ LED indicators (ON/OFF/PULSING/WAITING/COMPLETED)
- π Timeline view with current position marker
- β±οΈ Time tracking (upload time, total elapsed, protocol elapsed per channel)
π HTML Visualization Guide - Complete visualization features
# View all calibrations with age and expiration status
python utils/manage_calibrations.py list
# Test board identification
python test_board_info.py
# Export calibrations
python utils/manage_calibrations.py export backup.txt
# Delete specific calibration
python utils/manage_calibrations.py delete <board_id>π Database Management - Complete calibration system guide
- β Automatic calibration - π Board-specific with 90-day expiration
- β Multi-board support - π Different calibrations per Arduino
- β Precise timing - Compensates for crystal oscillator variations
- β Flexible timing - Milliseconds to hours
- β Start time scheduling - Time-of-day or countdown
- β Pattern compression - Up to 97% reduction in command count
- β Automatic verification - Arduino compatibility checking
- β Efficiency analysis - Optimal pattern_length recommendations
- β Multi-channel control - Up to 8 channels
- β Native pulsing support - Hardware PWM for frequency and duty cycle modulation
- β Real-time visualization - π¨ Interactive HTML with live status tracking
- β Auto-generated timelines - Visual protocol representation
- β Multiple formats - Excel and Text protocols
- β Command preview - Test without hardware
- β Flexible protocols - π Automatic or preset calibration
π Features Overview - Complete feature list with examples
The examples/ folder contains ready-to-use protocol files demonstrating both calibration approaches:
Located in examples/auto_calibration/ - Uses automatic calibration system:
| File | Format | Description | Pattern Length |
|---|---|---|---|
simple_blink_example.txt |
TXT | Basic ON/OFF patterns | 2 |
simple_blink_example.xlsx |
Excel | Same as TXT (no calibration sheet) | 2 |
pulse_protocol.txt |
TXT | Multi-channel pulsed patterns | 4 |
pulse_protocol.xlsx |
Excel | Same as TXT | 4 |
multi_channel_pattern.txt |
TXT | Complex 4-element patterns | 4 |
multi_channel_pattern.xlsx |
Excel | Same as TXT | 4 |
Key Feature: No CALIBRATION_FACTOR (TXT) or no calibration sheet (Excel) = automatic calibration enabled!
π Auto-Calibration Examples Guide
Located in examples/preset_calibration/ - Uses manual CALIBRATION_FACTOR:
| File | Format | Description | Pattern Length |
|---|---|---|---|
basic_protocol.txt/.xlsx |
Both | Simple channel control | 4 |
simple_blink_example.txt/.xlsx |
Both | ON/OFF blink patterns | 2 |
pulse_protocol.txt/.xlsx |
Both | Various pulsing effects | 4 |
wait_pulse_protocol.txt/.xlsx |
Both | Wait status with pulse | 4 |
pattern_length_4_example.txt/.xlsx |
Both | Complex 4-element patterns | 4 |
test_8_channels_pattern_length_4.txt |
TXT | All 8 channels | 4 |
Contains: Manual CALIBRATION_FACTOR: 1.000000 in each protocol
π Preset Calibration Examples Guide - Includes board-specific calibration explanation
Additional examples in examples/ root:
clean_protocol.txt- Minimal template without commentscomplete_protocol.txt- Fully documented with all features
π Complete Examples Guide - All examples explained
π Quick Reference - Fast example lookup
π Complete Documentation Index & Navigation Guide
Comprehensive guide to all 50+ documentation files organized by topic, user journey, and task.
New Users:
Installation β Arduino Setup β Usage Guide β Examples
Create Protocol:
Protocol Formats β Templates β Examples
Optimize Performance:
Pattern Compression β Verification
Calibration:
Auto-Calibration Guide β Backward Compatibility β Calibration Methods
Troubleshoot:
Troubleshooting β Common Issues
Develop:
Refactoring Guide β Folder Structure
π Expand Full Documentation Categories
- Installation Guide - Complete setup
- Arduino Setup - Hardware configuration
- Usage Guide - Basic and advanced usage
- Quick Start Examples - Ready-to-use protocols
- Automatic Calibration Database - Complete system guide
- Backward Compatibility - How old protocols work
- Calibration Guide - Understanding timing calibration
- Calibration Methods - V1, V1.1, V2 comparison
- Calibration Quick Reference - Quick lookup
- Features Overview - Complete feature list
- Protocol Formats - Excel & Text specifications
- Protocol Settings - Configuration parameters
- Templates - Ready-to-use templates
- Troubleshooting - Common issues
- Pattern Compression Guide - How it works
- Pattern Length Verification - Compatibility checking
- Pattern Length Implementation - Technical details
- HTML Visualization - Real-time monitoring
- Visualization Guide - Complete features
- Command Preview - Test without hardware
- Compile-Time Pulse Memory - Pulse configuration
- Pulse Period vs Section Time -
β οΈ IMPORTANT - Memory Reporting - Usage and compatibility
- Refactoring Guide - Class-based architecture
- Folder Structure - Project organization
- Build Instructions - Creating executables
- Utility Scripts - Development tools
Supported Formats:
- Text (.txt) - Version control friendly, command syntax
- Excel (.xlsx) - Visual editing with spreadsheet interface
Automatic Calibration (Recommended):
# TXT: Simply omit CALIBRATION_FACTOR line
PATTERN:1;CH:1;STATUS:1,0;TIME_MS:1000,1000;REPEATS:10
START_TIME: {'CH1': 0}
# Excel: Omit 'calibration' sheet
# System automatically identifies Arduino and applies stored calibrationPreset Calibration (Legacy):
# TXT: Include CALIBRATION_FACTOR
PATTERN:1;CH:1;STATUS:1,0;TIME_MS:1000,1000;REPEATS:10
START_TIME: {'CH1': 0}
CALIBRATION_FACTOR: 1.025847 # Board-specific value!
# Excel: Include 'calibration' sheet with factorPATTERN commands (at least one per channel):
PATTERN:<id>;CH:<channel>;STATUS:<states>;TIME_MS:<durations>;REPEATS:<count>;PULSE:<optional>START_TIME (for all channels):
START_TIME: {'CH1': '21:00', 'CH2': 60, 'CH3': '2025-11-08 21:00:00'}WAIT_STATUS, WAIT_PULSE, CALIBRATION_FACTOR (see docs for details)
π Complete Protocol Syntax
π Protocol Settings Guide
π Templates
light_controller_v2.2/
βββ protocol_parser.py # Main execution script
βββ preview_protocol.py # Preview without Arduino
βββ viz_protocol_html.py # HTML visualization generator
βββ light_controller_parser.py # Core parser class
βββ lcfunc.py # Utility functions
βββ test_board_info.py # π Arduino board identification test
βββ calibration_database.json # π Stored calibrations (auto-generated)
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ CHANGELOG.md # Version history
β
βββ examples/ # Example protocol files
β βββ auto_calibration/ # π Automatic calibration examples
β β βββ README.md # Auto-calibration guide
β β βββ simple_blink_example.txt/.xlsx
β β βββ pulse_protocol.txt/.xlsx
β β βββ multi_channel_pattern.txt/.xlsx
β β βββ create_excel_examples.py # Script to generate Excel examples
β β
β βββ preset_calibration/ # π Manual calibration examples (legacy)
β β βββ README.md # Preset calibration guide
β β βββ simple_blink_example.txt/.xlsx
β β βββ pulse_protocol.txt/.xlsx
β β βββ basic_protocol.txt/.xlsx
β β βββ wait_pulse_protocol.txt/.xlsx
β β βββ ... (more examples)
β β
β βββ README.md # Complete examples guide
β βββ QUICK_REFERENCE.md # Quick lookup
β βββ clean_protocol.txt # Minimal template
β βββ complete_protocol.txt # Fully documented example
β
βββ docs/ # Documentation (50+ guides)
β βββ DOCUMENTATION_INDEX.md # π Complete navigation guide
β βββ AUTO_CALIBRATION_DATABASE.md # π Calibration system
β βββ BACKWARD_COMPATIBILITY.md # π Legacy protocol support
β βββ PATTERN_COMPRESSION_GUIDE.md # Optimization
β βββ HTML_VISUALIZATION.md # Real-time monitoring
β βββ ... (40+ more guides)
β
βββ utils/ # Utility & development tools
β βββ manage_calibrations.py # π Calibration database manager
β βββ debug_calibration_speed_test.py
β βββ verify_pattern_length_fix.py
β βββ README.md
β
βββ light_controller_v2_2_arduino/ # Arduino firmware
βββ light_controller_v2_2_arduino.ino
π New in v2.2.1:
calibration_database.json- Auto-generated calibration storageexamples/auto_calibration/- Automatic calibration examplesexamples/preset_calibration/- Legacy manual calibration examplestest_board_info.py- Arduino identification testingutils/manage_calibrations.py- Database management utilitydocs/AUTO_CALIBRATION_DATABASE.md- Complete calibration guidedocs/BACKWARD_COMPATIBILITY.md- Legacy protocol compatibility
| Topic | Documentation |
|---|---|
| Setup | Installation β Arduino Setup |
| Calibration | Auto-Calibration β Backward Compatibility |
| Creating Protocols | Protocol Formats β Templates β Examples |
| Optimization | Pattern Compression β Verification |
| Timing Issues | Calibration Guide β Calibration Methods |
| Pulse Control | Pulse Period vs Section Time β Pulse Memory |
| Visualization | HTML Visualization β Realtime Features |
| Development | Refactoring Guide β Folder Structure |
| Troubleshooting | Troubleshooting Guide β Common Bugs |
- π Documentation Index - Complete navigation to all 50+ guides
- π Documentation Folder - Browse all guides by category
- π GitHub Issues - Report bugs or request features
- π‘ Examples - Ready-to-use protocol templates
- π§ Troubleshooting - Common issues and solutions
Version: 2.2.2
Status: Production Ready β
Tested: Python 3.6-3.13, Arduino Uno/Due/Mega
License: MIT
- v2.2.2 (Dec 12, 2025) - Improved serial communication reliability for PULSE commands, fixed calibration skip issue
- v2.2.1 (Nov 10, 2025) - Automatic calibration system with 3-month expiration, examples reorganization
- v2.2.0 (Nov 8, 2025) - Pattern compression, auto-verification, real-time visualization
- v2.1.0 (Nov 3, 2025) - Text protocol support, multiple time units
- v2.0.0 - Initial release
π Complete Changelog
Contributions are welcome! Please:
- Read the Documentation Index
- Review Folder Structure
- Understand Refactoring Guide
- Submit pull requests with clear descriptions
Built with:
- Python - Protocol parsing and serial communication
- Arduino - Hardware control
- NumPy - Data processing
- Pandas - Protocol parsing (Excel)
- PySerial - Serial communication
- openpyxl - Excel file handling
Happy light controlling! π‘
Need calibration help? See Automatic Calibration Guide
Want to understand why calibration factors are board-specific? See Preset Calibration Examples