Using the IS31FL3741 with Arduino involves wiring up the matrix to your Arduino-compatible microcontroller, installing the Adafruit IS31FL3741 library, and running the provided example code.

I2C Wiring

Here is how to wire up the matrix using one of the STEMMA QT connectors. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.

  • Connect matrix VCC (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect matrix GND (black wire) to Arduino GND
  • Connect matrix SCL (yellow wire) to Arduino SCL
  • Connect matrix SDA (blue wire) to Arduino SDA

Here is how to wire the matrix to a board using a solderless breadboard:

  • Connect matrix VCC (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect matrix GND (black wire) to Arduino GND
  • Connect matrix SCL (yellow wire) to Arduino SCL
  • Connect matrix SDA (blue wire) to Arduino SDA

Library Installation

You can install the Adafruit IS31FL3741 library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for IS31FL3741 , and select the Adafruit IS31FL3741 library, and install the latest version:

If asked about dependencies, click "Install all".

Load Rainbow Example

Open up File -> Examples -> Adafruit IS31FL3741 Library -> qtmatrix-rgbswirl

// Rainbow swirl example for the Adafruit IS31FL3741 13x9 PWM RGB LED
// Matrix Driver w/STEMMA QT / Qwiic connector. This is the simplest
// version and should fit on small microcontrollers like Arduino Uno.
// Tradeoff is that animation isn't always as smooth as seen in the
// buffered example. Each LED changes state immediately when accessed,
// there is no show() or display() function as with NeoPixels or some
// OLED screens.

#include <Adafruit_IS31FL3741.h>

Adafruit_IS31FL3741_QT ledmatrix;
// If colors appear wrong on matrix, try invoking constructor like so:
// Adafruit_IS31FL3741_QT ledmatrix(IS3741_RBG);

// Some boards have just one I2C interface, but some have more...
TwoWire *i2c = &Wire; // e.g. change this to &Wire1 for QT Py RP2040

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit QT RGB Matrix Simple RGB Swirl Test");

  if (! ledmatrix.begin(IS3741_ADDR_DEFAULT, i2c)) {
    Serial.println("IS41 not found");
    while (1);
  }

  Serial.println("IS41 found!");

  // By default the LED controller communicates over I2C at 400 KHz.
  // Arduino Uno can usually do 800 KHz, and 32-bit microcontrollers 1 MHz.
  i2c->setClock(800000);

  // Set brightness to max and bring controller out of shutdown state
  ledmatrix.setLEDscaling(0xFF);
  ledmatrix.setGlobalCurrent(0xFF);
  Serial.print("Global current set to: ");
  Serial.println(ledmatrix.getGlobalCurrent());
  ledmatrix.enable(true); // bring out of shutdown
}

uint16_t hue_offset = 0;

void loop() {
  uint32_t i = 0;
  for (int y=0; y<ledmatrix.height(); y++) {
    for (int x=0; x<ledmatrix.width(); x++) {
      uint32_t color888 = ledmatrix.ColorHSV(i * 65536 / 117 + hue_offset);
      uint16_t color565 = ledmatrix.color565(color888);
      ledmatrix.drawPixel(x, y, color565);
      i++;
    }
  }

  hue_offset += 256;

  ledmatrix.setGlobalCurrent(hue_offset / 256); // Demonstrate global current
}

After opening the demo file, upload to your Arduino wired up to the matrix. Once you upload the code, you'll see the matrix light up in a rainbow pattern!

This demo does a simple example showing how to set the color of each pixel using ledmatrix.drawPixel(x, y, color565) - where x and y are the 0-12 and 0-8 indexed location indicator, and color565 is the 16-bit packed color. We use ledmatrix.ColorHSV to get a rainbow color across the spectrum.

Load GFX Example

Open up File -> Examples -> Adafruit IS31FL3741 Library -> qtmatrix-text

// Scrolling text example for the Adafruit IS31FL3741 13x9 PWM RGB LED
// Matrix Driver w/STEMMA QT / Qwiic connector. This is the simplest
// version and should fit on small microcontrollers like Arduino Uno.
// Tradeoff is that animation isn't always as smooth as seen in the
// buffered example. Each LED changes state immediately when accessed,
// there is no show() or display() function as with NeoPixels or some
// OLED screens.

#include <Adafruit_IS31FL3741.h>

Adafruit_IS31FL3741_QT matrix;
// If colors appear wrong on matrix, try invoking constructor like so:
// Adafruit_IS31FL3741_QT matrix(IS3741_RBG);

// Some boards have just one I2C interface, but some have more...
TwoWire *i2c = &Wire; // e.g. change this to &Wire1 for QT Py RP2040

char text[] = "ADAFRUIT!";   // A message to scroll
int text_x = matrix.width(); // Initial text position = off right edge
int text_y = 1;
int text_min;                // Pos. where text resets (calc'd later)

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit QT RGB Matrix Scrolling Text Test");

  if (! matrix.begin(IS3741_ADDR_DEFAULT, i2c)) {
    Serial.println("IS41 not found");
    while (1);
  }

  Serial.println("IS41 found!");

  // By default the LED controller communicates over I2C at 400 KHz.
  // Arduino Uno can usually do 800 KHz, and 32-bit microcontrollers 1 MHz.
  i2c->setClock(800000);

  // Set brightness to max and bring controller out of shutdown state
  matrix.setLEDscaling(0xFF);
  matrix.setGlobalCurrent(0xFF);
  Serial.print("Global current set to: ");
  Serial.println(matrix.getGlobalCurrent());

  matrix.fill(0);
  matrix.enable(true); // bring out of shutdown
  matrix.setRotation(0);
  matrix.setTextWrap(false);

  // Get text dimensions to determine X coord where scrolling resets
  uint16_t w, h;
  int16_t ignore;
  matrix.getTextBounds(text, 0, 0, &ignore, &ignore, &w, &h);
  text_min = -w; // Off left edge this many pixels
}

void loop() {
  matrix.setCursor(text_x, text_y);
  for (int i = 0; i < (int)strlen(text); i++) {
    // set the color thru the rainbow
    uint32_t color888 = matrix.ColorHSV(65536 * i / strlen(text));
    uint16_t color565 = matrix.color565(color888);
    matrix.setTextColor(color565, 0); // backound is '0' to erase previous text!
    matrix.print(text[i]); // write the letter
  }

  if (--text_x < text_min) {
    text_x = matrix.width();
  }

  delay(25);
}

After opening the demo file, upload to your Arduino wired up to the matrix. Once you upload the code, a scrolling rainbow ADAFRUIT! will show up on your matrix!

This demo uses more of the Adafruit_GFX library to draw text, check out the guide for Adafruit GFX to learn how to draw circles, lines, triangles, etc!

 

This guide was first published on Sep 22, 2021. It was last updated on Sep 22, 2021.

This page (Arduino) was last updated on Sep 10, 2021.

Text editor powered by tinymce.