It's easy to use the IS31FL3741 matrix with Python and CircuitPython, and the Adafruit CircuitPython IS31FL3741 module. This module allows you to easily write Python code that controls the LEDs.
You can use this sensor with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
CircuitPython Microcontroller Wiring
First wire up a IS31FL3741 matrix to your board exactly as shown below. Here's an example of wiring a Feather M4 to the matrix driver breakout with I2C using one of the handy STEMMA QT connectors:
- Board 3V to matrix VCC (red wire)
- Board GND to matrix GND (black wire)
- Board SCL to matrix SCL (yellow wire)
- Board SDA to matrix SDA (blue wire)
You can also use the standard 0.100" pitch headers to wire it up on a breadboard:
- Board 3V to matrix VCC (red wire)
- Board GND to matrix GND (black wire)
- Board SCL to matrix SCL (yellow wire)
- Board SDA to matrix SDA (blue wire)
Python Computer Wiring
Since there's dozens of Linux computers/boards you can use, we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired to the matrix driver breakout using I2C and a STEMMA QT connector:
- Pi 3V3 to matrix VCC (red wire)
- Pi GND to matrix GND (black wire)
- Pi SCL to matrix SCL (yellow wire)
- Pi SDA to matrix SDA (blue wire)
Finally here is an example of how to wire up a Raspberry Pi to the sensor using a solderless breadboard:
- Pi 3V3 to matrix VCC (red wire)
- Pi GND to matrix GND (black wire)
- Pi SCL to matrix SCL (yellow wire)
- Pi SDA to matrix SDA (blue wire)
Python Installation of IS31FL3741 Library
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
pip3 install adafruit-circuitpython-is31fl3741
If your default Python is version 3, you may need to run pip
instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
CircuitPython Usage
To use with CircuitPython, you need to first install the IS31FL3741 library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and file:
- adafruit_bus_device/
- adafruit_register/
- adafruit_is31fl3741/
- adfruit_framebuf.mpy

Python Usage
Once you have the library pip3
installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file: python3 code.py
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import adafruit_is31fl3741 i2c = board.I2C() # uses board.SCL and board.SDA # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller is31 = adafruit_is31fl3741.IS31FL3741(i2c) is31.set_led_scaling(0xFF) # turn on LEDs all the way is31.global_current = 0xFF # set current to max is31.enable = True # enable! # light up every LED, one at a time while True: for pixel in range(351): is31[pixel] = 255 time.sleep(0.01) is31[pixel] = 0
The LEDs light up one at a time, various colors, and in an arbitrary order!
First you import the necessary modules and library. Then you create the IS31FL3741
object, provide it the board.I2C()
object, and save it to is31
.
Next, you do the basic setup needed to control the LEDs. You set all the LEDs to maximum brightness with set_led_scaling()
, set the current to max with global_current
, and enable them by setting enable
to True
.
Then, inside your loop, you have a for
loop iterating over the entire set of pixels (351 total!), and turning on each one individually for 0.01 seconds before turning it off and moving on to the next one.
Rainbow Example Code:
To run this example, you need to update your code.py file.
Click the Download Project Bundle button below to download the code.py file (and the libraries, though you don't need to update them again) in a zip file. Extract the contents of the zip file, and copy the code.py file to your CIRCUITPY drive.
Your CIRCUITPY drive should resemble the image below.

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import board from rainbowio import colorwheel from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT import adafruit_is31fl3741 i2c = board.I2C() # uses board.SCL and board.SDA # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller is31 = Adafruit_RGBMatrixQT(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER) is31.set_led_scaling(0xFF) is31.global_current = 0xFF # print("Global current is: ", is31.global_current) is31.enable = True # print("Enabled? ", is31.enable) wheeloffset = 0 while True: for y in range(9): for x in range(13): is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset)) wheeloffset += 1 is31.show()
The matrix lights up in a slow-moving rainbow pattern!
That's all there is to using the IS31FL3741 LED matrix driver with CircuitPython!
Page last edited January 22, 2025
Text editor powered by tinymce.