Overview
Kinematrix provides powerful LED control capabilities through the PCF8574Module, allowing you to control up to 8 LEDs per I2C expander chip. This guide covers basic LED control, patterns, and integration with sensors.Hardware Setup
PCF8574 I2C Expander
- Address: 0x20 (default, configurable with A0-A2 pins)
- Interface: I2C (SDA, SCL)
- Outputs: 8 digital outputs (PCF_PIN0 to PCF_PIN7)
- Voltage: 5V compatible
Wiring
Basic LED Control
LED Patterns and Effects
Sequential Chase Pattern
LEDs light up one after another in sequence:Knight Rider / Cylon Effect
A single LED sweeps back and forth:Blink All LEDs
Flash all LEDs on and off:Alternating Pattern
Odd and even LEDs alternate:Complete Example: All Patterns
Here’s the complete example demonstrating multiple LED patterns:Sensor-Triggered LED Control
Combine LED control with sensor readings:Advanced Techniques
Using Multiple PCF8574 Modules
Control up to 64 LEDs (8 modules) on the same I2C bus:Binary Counter Display
Display binary numbers on 8 LEDs:PWM-like Brightness Control
Simulate PWM by rapidly toggling LEDs:PCF8574 API Reference
Initialization
LED Setup
Individual LED Control
Bulk Control
Troubleshooting
PCF8574 not detected
PCF8574 not detected
- Verify I2C address using I2C scanner
- Check SDA/SCL connections
- Ensure pull-up resistors on I2C lines (usually built-in)
- Try different I2C address (0x20-0x27)
LEDs not lighting up
LEDs not lighting up
- Check LED polarity (anode to resistor, cathode to GND)
- Verify appropriate resistor value (220Ω - 1kΩ)
- Test with
digitalWriteAll(0xFF)to turn all on - Check power supply can handle current draw
LEDs dim or flickering
LEDs dim or flickering
- Increase resistor values if LEDs too bright
- Check power supply capacity
- Reduce number of LEDs lit simultaneously
- Add capacitor (100µF) across power supply
Next Steps
IoT Data Logger
Log data and trigger LED alerts
Multi-Platform Development
Deploy LED control across platforms
Debugging
Debug LED and I2C issues
Basic Sensor Reading
Integrate sensors with LED feedback