The Adafruit 24-Channel 12-bit PWM LED Driver is an efficient and versatile solution for controlling multiple LEDs. Utilizing Pulse Width Modulation (PWM), this driver can manage the brightness of up to 24 individual LEDs with 12-bit resolution, allowing for smooth and precise light output control. The module communicates via the Serial Peripheral Interface (SPI), making it compatible with a wide range of microcontrollers, including Arduino boards. Common applications include LED displays, lighting projects, and custom electronics requiring variable LED intensity.
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | V+ | Power supply (5V-6V) |
3 | SCLK | Serial Clock for SPI |
4 | MOSI | Master Out Slave In for SPI data |
5 | LATCH | Latch pin to update outputs |
6 | OE | Output Enable (active low) |
7-30 | OUT0-OUT23 | Output pins for each of the 24 channels |
#include <SPI.h>
// Define the SPI pins for Arduino UNO
#define LATCH_PIN 10
#define OE_PIN 9
void setup() {
// Set the latch and output enable pins as outputs
pinMode(LATCH_PIN, OUTPUT);
pinMode(OE_PIN, OUTPUT);
// Begin SPI communication
SPI.begin();
// Set output enable to low (enable outputs)
digitalWrite(OE_PIN, LOW);
}
void loop() {
// Example: Set all channels to mid brightness
for (int i = 0; i < 24; i++) {
sendPWM(i, 2048); // 2048 is half of 4096 (mid brightness)
}
// Latch the PWM values to update the outputs
latchPWM();
// A delay to see the change in brightness
delay(1000);
}
void sendPWM(int channel, int value) {
// Ensure the value is within 12-bit range
value = value & 0xFFF;
// Calculate the command byte and the two data bytes
byte command = 0b11100000 | (channel >> 4);
byte data1 = (channel << 4) | (value >> 8);
byte data2 = value & 0xFF;
// Send the bytes via SPI
SPI.transfer(command);
SPI.transfer(data1);
SPI.transfer(data2);
}
void latchPWM() {
// Pulse the latch pin to update the LED outputs
digitalWrite(LATCH_PIN, HIGH);
delayMicroseconds(10); // Short pulse
digitalWrite(LATCH_PIN, LOW);
}
Q: Can I chain multiple LED drivers together? A: Yes, you can chain multiple drivers by connecting the MOSI out of the first driver to the MOSI in of the next driver, and so on. Each driver will need its own LATCH pin control.
Q: What is the maximum number of LEDs I can control with this driver? A: You can control up to 24 LEDs with a single driver. However, by chaining multiple drivers, you can control more LEDs.
Q: Can I use this driver with a 3.3V microcontroller? A: While the driver itself requires a 5V-6V supply, logic level converters can be used to interface with 3.3V logic levels on the control pins.