Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use Adafruit 24-Channel 12-bit PWM LED Driver - SPI: Examples, Pinouts, and Specs

Image of Adafruit 24-Channel 12-bit PWM LED Driver - SPIDesign with Adafruit 24-Channel 12-bit PWM LED Driver - SPI in Cirkit Designer

Introduction

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.

Explore Projects Built with Adafruit 24-Channel 12-bit PWM LED Driver - SPI

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino-Controlled Servo Driver for Multi-Channel PWM Applications: A project utilizing Adafruit 24-Channel 12-bit PWM LED Driver - SPI in a practical application
Arduino-Controlled Servo Driver for Multi-Channel PWM Applications

This circuit is designed to control multiple servo motors using an Arduino Mega 2560 microcontroller and an Adafruit 16-Channel 12-bit PWM Servo Driver. The Arduino communicates with the PWM driver over I2C (using SDA and SCL lines) to send PWM signals to individual servos for precise angle control. A separate 5V power supply provides power to the PWM driver and the servos, ensuring stable operation for high-current applications.

Open Project in Cirkit Designer
Image of Raspberry Pi 5 Controlled Traffic Light System with PWM Servo Driver: A project utilizing Adafruit 24-Channel 12-bit PWM LED Driver - SPI in a practical application
Raspberry Pi 5 Controlled Traffic Light System with PWM Servo Driver

This circuit features a Raspberry Pi 5 microcontroller connected to an Adafruit 16-Channel 12-bit PWM Servo Driver via I2C communication protocol, which in turn controls multiple traffic lights and individual green LEDs. The Raspberry Pi provides power and ground connections to the PWM driver, and the driver outputs PWM signals to control the red, yellow, and green lights of each traffic light, as well as additional green LEDs. The purpose of this circuit is likely to simulate a traffic light control system, with the capability to individually manage each light's state.

Open Project in Cirkit Designer
Image of Arduino Nano Controlled Robotics System with Wireless Communication and Touch Sensing: A project utilizing Adafruit 24-Channel 12-bit PWM LED Driver - SPI in a practical application
Arduino Nano Controlled Robotics System with Wireless Communication and Touch Sensing

This circuit features two Arduino Nanos controlling a variety of components. One Arduino interfaces with a 12-bit PWM servo driver to manage multiple servos, an OLED display, a stepper motor via an A4988 driver, and communicates using an NRF24L01 wireless module. The other Arduino handles inputs from several TTP233 touch sensors and also communicates wirelessly using its own NRF24L01 module. Power management is handled by a 12V battery, a step-down converter to 5V, and rocker switches to control power flow.

Open Project in Cirkit Designer
Image of Arduino-Controlled Multi-Servo Positioning System with Potentiometer Feedback: A project utilizing Adafruit 24-Channel 12-bit PWM LED Driver - SPI in a practical application
Arduino-Controlled Multi-Servo Positioning System with Potentiometer Feedback

This circuit uses an Arduino UNO to control five servos through an Adafruit 16-Channel 12-bit PWM Servo Driver, with the position of each servo being adjusted by a corresponding potentiometer. The Arduino reads the analog values from the potentiometers connected to its analog inputs and sends PWM signals to the servos via the I2C-connected PWM driver. The servos are powered by a separate power supply that also powers the PWM driver, ensuring adequate current for servo operation.

Open Project in Cirkit Designer

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

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

Usage Instructions

Connecting to a Circuit

  1. Connect the GND pin to the ground of your power supply and microcontroller.
  2. Connect the V+ pin to a 5V-6V power supply.
  3. Connect the SCLK, MOSI, and LATCH pins to the corresponding SPI pins on your microcontroller.
  4. Connect the OE pin to a digital pin on your microcontroller if you wish to use the output enable feature.
  5. Connect each OUT pin to the anode of an LED, and connect the cathode of the LEDs to ground.

Best Practices

Example Code for Arduino UNO

#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);
}

Troubleshooting and FAQs

Common Issues

Solutions and Tips

FAQs

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.