AutoLight V3 provides a comprehensive LED control system for ESP32 with dynamic PCF8574 I2C expander support. This guide demonstrates basic LED control patterns using the BaseChannel class.
1
Hardware Setup
Connect your PCF8574 I2C expanders to the ESP32:
SDA: GPIO 21 (default)
SCL: GPIO 22 (default)
PCF8574 Addresses: 0x20-0x27 (up to 8 devices)
Power: 3.3V or 5V depending on your PCF8574 variant
Each PCF8574 provides 8 GPIO pins for LED control.
BaseChannel led;BaseConfig config;void setup() { Serial.begin(115200); // Configure 12 LED channels across 2 PCF8574 devices config.setDynamicConfig(12, 2); // Attach configuration to LED controller led.attachConfig(config.getConfigData()); // Initialize the system led.initialize();}
Here’s a complete working example that sets up a 12-channel LED system:
#define ENABLE_ADDONS_AUTOLIGHT_V3#include "Kinematrix.h"using namespace AutoLight;BaseChannel led;BaseConfig config;void setup() { Serial.begin(115200); Serial.println("AutoLight V3 - Basic LED Control"); // Configure 12 channels across 2 PCF8574 devices // Default addresses: 0x20 and 0x21 config.setDynamicConfig(12, 2); // Set initial sequence mode (2 = Blink All) led.setInitSequence(2); // Set delay time between LED updates (milliseconds) led.setInitDelay(50); // Attach configuration to LED controller led.attachConfig(config.getConfigData()); // Initialize the LED system if (led.initialize()) { Serial.println("LED system initialized successfully"); } else { Serial.println("LED initialization failed!"); }}void loop() { // Run the AutoLight system led.runAutoLight(); delay(10);}
// Navigate through modesled.nextMode(); // Go to next sequenceled.previousMode(); // Go to previous sequence// Direct controlled.onMode(); // Turn all LEDs on (mode 1)led.offMode(); // Turn all LEDs off (mode 0)// Get current stateint currentMode = led.getSequenceIndex();int currentDelay = led.getDelayTime();