Maker.io main logo

Enable your Teensy with a Colorful LED Display Shield

2019-01-03 | By Maker.io Staff

License: See Original Project Programmers Arduino Teensy

Knock out your next design with a colorful LED Matrix display realized by a unique board that can make designing easier when trying to impress your audience with moving RGB LEDs built into a cost effect panel. Using a SmartLED Shield driven by a Teensy via I2C is all explained by SparkFun in the following project, check it out!

Courtesy of SparkFun

Introduction

The PixelMatix SmartLED shield for Teensy makes it easy to connect to RGB LED matrix panels! The shield makes it easy to connect to the 16 pins required to drive the display, connects an external 5V supply to power the display and Teensy, and brings out the Teensy’s free signals to a convenient header.

Figure 1

SmartLED Shield V4 for Teensy

In this tutorial, we will explore some of the examples provided with the SmartLED shield using different RGB LED matrix panel sizes.

Figure 2

Required Materials

To follow along with this tutorial, you will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

RGB LED Matrix Panel

You will need a panel. The following has been tested to work with the examples provided.

Heads Up! The comments in the example code indicate that the known working width are: “32, 64, 96, 128”. As for the height, the known working sizes are: 16, 32, 48, 64. If you dig into the library, the known working scan rates are:

  • 1:16 with 32 rows
  • 1:8 with 16 rows
  • 1:32 with 64 rows

For example, if you are trying to use a 32x32 panel with a 1:8 scan rate, it may not display as expected.

Teensy

To control the panel using the SmartLED shield, you will need a Teensy.

Power

You will also need a 5V power supply. A 5V wall adapter and barrel jack adapter is the easiest way to connect power to the panel and Teensy. However, there are other methods depending on how you are powering the panel.

Additional Components

Depending on your setup and how you are controlling the panel, you may need these additional components.

Tools

Depending on your setup, you may need pliers, a soldering iron, solder, and general soldering accessories.

Suggested Reading

If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.

  • How to Power a Project: A tutorial to help figure out the power requirements of your project.
  • What is an Arduino? What is this 'Arduino' thing anyway?
  • RGB Panel Hookup Guide: Make bright, colorful displays using the 32x16, 32x32, and 32x64 RGB LED matrix panels. This hookup guide shows how to hook up these panels and control them with an Arduino.
  • Getting Started with the Teensy: Basic intro to the Teensy line of products, with soldering and programming suggestions.

Hardware Overview

Teensy Footprint

The SmartLED shield makes it easy to connect to RGB LED matrix panels. As opposed to wiring to 16 pins on the RGB LED matrix panel, you simply sandwich the shield between a Teensy and the IDC connector! The top of the board is where you would insert the Teensy populated with straight headers. The bottom of the shield includes female headers to make a secure connection.

Figure 3

Adjacent to the Teensy footprint are additional pins that are broken out for easy access for prototyping or soldering wires directly to the shield.

Figure 4

For more information about the reserved pins on the SmartLED matrix shield, check out the image below for the pins that are used to drive the RGB LED matrix panel and APA102 LEDs.

Figure 5

Image Courtesy of PJRC and PixelMatix

Tip: If you are prototyping with the shield, try grabbing some square header pins, jumper wires, and a breadboard to connect. Make sure that the jumper wires are square pins for a secure connection with the female header populated on the bottom of the SmartLED shield.

IDC Connector

The shield breaks out the RGB LED matrix panel's IDC pins. Simply align the silkscreen with the panel's input and stack it on like a backpack. As an alternative, you can use an IDC cable and the included 2x8 long, centered header pins. Just make sure to align the cable’s red wire with the silkscreen labeled RED WIRE.

Figure 6

APA102 LED

The shield includes additional 4-pin JST SM connector pair to connect a strip or matrix of APA102 LEDs from the SmartLED Shield.

Figure 7

Removable Mounting Holes

The shield includes mounting holes by each corner of the board. They can be used to mount the shield when using the IDC cable. They are held to the rest of the board with mouse bites. Each of the mounting holes can be removed using pliers. The image below shows highlights the mounting holes with red lines along the mousebites.

Figure 8

Tip: If you are using a Teensy 3.5/3.6 with headers populated beyond the 1x14 pins along the side of a Teensy, you will need to snap off the mounting hole below pin 13.

Figure 9

ADDX Pins and Logic Levels

Certain panels may require 5V logic levels, which may not be enough with the Teensy's output pins. While you can try to wire all 16 pins from the Teensy to the IDC cable, it is not the most reliable connection. The panel may flicker or fail to display properly. The SmartLED shield was designed to include level shifting buffers to safely and reliably control the RGB LED matrix panels.

Figure 10

Hardware Assembly

If you have not already, solder the male header pins on your Teensy before connecting. We will be using the 1x14 header pins on each side of a Teensy but you can also solder additional pins or or wires depending on your setup.

Figure 11

After soldering and removing the flux from a Teensy, stack the Teensy on the SmartLED shield. Make sure to face the USB connector in the same direction as the 4-pin JST SM connector.

Figure 12

Align the IDC connector breakout on the SmartLED shield with the IDC connector on your RGB LED Matrix Panel. The location of the IDC connector depends on the manufacturer of the panel but usually it will be located on the left side relative to the arrows pointing up and toward the right.

Figure 13

Tip: If you received a shield with the 2x8 header pins installed and decide to add the shield to the RGB LED matrix panel's IDC connector as a backpack, you can remove the headers from the shield. Otherwise, you can leave the 2x8 header pins inserted and connect using the IDC cable.

Figure 14

Once connected, the back of your RGB LED matrix panel should look similar to the images below. On the left, a Teensy 3.2 was connected to a 64x64 panel with 3mm pitched LEDs. On the right, a Teensy 3.6 was used for a 32x32 with 6mm pitched LEDs.

Figure 15

If you have not already, attach a 5V power supply to your RGB LED matrix panel's power cable. If you are using a power supply with a barrel jack, you can use a female barrel jack adapter and screwdriver to get a quick and dirty connection between the spade and barrel jack.

Figure 16

The connection should look similar to the image below. Depending on your 5V power supply, your setup might be slightly different.

Figure 17

Then slide the polarized power cable for the RGB matrix panel into its respective mating connector. The red wires should be connected to the 5V pins while the black wires connected to the GND pins.

Figure 18

For the scope of this tutorial, we will connect 5V USB power directly to the Teensy's USB connector. This is separate from the power supply that is powering the RGB LED matrix panel. Depending on your setup, you can use the same power supply that the RGB LED matrix panel is using by connecting to either the Teensy's V and GND pins or the APA102 JST SM connector. Just make sure that the voltage is regulated at 5V.

Figure 19

Heads up! When powering the Teensy via the micro-B connector, make sure to hold the connector against the PCB with your thumb and index finger while inserting the cable to avoid pulling the USB connector off. If you plan on moving the panel frequently, you may want to consider connecting power the Teensy from either the SmartLED shield's V and GND pins, or the APA102 JST SM connector.

Alternative Connections

There is an option to daisy chain the panels together if you are within the limits of the SmartLED library. Simply connect the output from the first panel to the input of the second panel. Make sure to provide power to each panel through the 4-pin polarized connector.

Figure 20

As explained earlier, you can try to wire all 16 pins from the Teensy to the panel's IDC cable. It is not the most reliable connection. There is a higher probability of wiring incorrectly or a connection becoming loose. For more information on trying the connection, check out the table below. This connection is not possible when wiring to a 64x64 panel due to the extra 5th addressing pin.

Figure 21

Heads up! When manually wiring the board to the panel, make sure that the latch pin is connected to both pins 3 and 8 on the Teensy! Doesn't the SmartLED shield sound good right about now?

Figure 22

Image courtesy of PixelMatix: Manually Connecting Teensy and Panel

Software Installation

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

Teensyduino Add-On

If you haven’t used Teensy before, you’ll need to download and install the extension for the Arduino IDE called Teensyduino from PJRC. This will also install the drivers for the board. Follow the instructions on installing the add-on before continuing on.

PJRC: TEENSYDUINO DOWNLOAD PAGE

Install Library

Louis Beaudoin has written an amazing library to control the RGB LED matrix panels. You can obtain these libraries through the Arduino Library Manager. Search for SmartMatrix3 and you should be able to install the latest version. If you prefer downloading the libraries manually you can also grab them from the GitHub repository:

GITHUB PIXELMATIX - SMARTMATRIX (ZIP)

Compatibility: When trying to use other examples that were written for other platforms (such as the Serial Paint Example for Arduino Uno or Arduino Mega), they may not be compatible with the Teensy due to the different chipset.

Library Overview

For an overview of the functions, check out documentation in the MIGRATION.md file from the GitHub repository.

GIBHUBPIXELMATIX DOCS - SMARTMATRIX LIBRARY OVERVIEW

Example: Feature Demo!

There are a few examples from the SmartMatrix library for the SmartLED Shield. For the scope of the tutorial, we will be highlighting three of the examples.

Feature Demo!

Let's start with the feature demo. After installing the library, click File > Examples > SmartMatrix3 > FeatureDemo.ino in the Arduino IDE. Once open, there are a minimum of 4 lines to modify to get the example working with your matrix panel:

  • uncomment line “#include <SmartLEDShieldV4.h>” if you are using the shield
  • adjust kMatrixWidth to the width of your panel
  • adjust kMatrixHeight to the height of your panel
  • adjust kPanelType based on the scan rate of your panel from line 34 in SmartMatrix3.h

Heads Up! The comments in the example code indicate that he known working width are: “32, 64, 96, 128”. As for the height, the known working sizes are: 16, 32, 48, 64. If you dig into the library, the known working scan rates are:

  • 1:16 with 32 rows
  • 1:8 with 16 rows
  • 1:32 with 64 rows

For example, if you are trying to use a 32x32 panel with a 1:8 scan rate, it may not display as expected.

64x64 Panel with 1:32 Scan Rate

Let's try modifying the example code to work with the 64x64 panel with a 1:32 scan rate. The SmartLED shield is required to address the extra 5th ADDX pin on the IDC connector.

Parts Needed

To follow this example, you would will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Wishlist for 64x64 Panel with 1:32 Scan Rate Example SparkFun Wish List:

Modifying Code

Adjust the code by simply:

  • uncommenting line “#include <SmartLEDShieldV4.h>” by removing the “//
  • adjusting kMatrixWidth to the width of your panel by replacing 32 with 64
  • adjusting kMatrixHeight to the height of your panel by replacing 32 with 64
  • adjusting kPanelType by replacing SMARTMATRIX_HUB75_32ROW_MOD16SCAN with SMARTMATRIX_HUB75_64ROW_MOD32SCAN from line 34 in SmartMatrix3.h

Upload Code

When the changes are completed, select the Teensy board definition with the associated COM port and click upload. You should see the feature demo running. This includes scrolling text, animations, shapes being drawn, brightness changing, and refresh rate changing.

Figure 23

Daisy Chained 32x64 with 1:16 Scan Rate

Let's try modifying the example code to work with two 32x64 panels with a 1:16 scan rate. In this example, we manually wire the connection to a Teensy 3.2.

Parts Needed

To follow this example, you would will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Wishlist for Daisy Chained 32x64 with 1:16 Scan Rate SparkFun Wish List:

Modifying Code

Modify the original code by:

  • leaving the line “#include <SmartLEDShieldV4.h>” commented out by using the “//
  • adjusting kMatrixWidth to the width of your panel by replacing 32 with 128
  • keeping kMatrixHeight the height of your panel by leaving 32 at 32
  • keeping kPanelType by leaving SMARTMATRIX_HUB75_32ROW_MOD16SCAN at SMARTMATRIX_HUB75_32ROW_MOD16SCAN from line 34 in SmartMatrix3.h

Upload Code

When the changes are completed, select the Teensy board definition with the associated COM port and click upload. You should see the same demo running but for a matrix size of 32x128!

Figure 24

Example: Matrix Clock w/ the DS1307 RTC Module

In this example, we will be using the DS1307 RTC module with the SmartLED Shield, Teensy 3.2, and 32x32 panel with 1:16 scan rate. We will use the included 2x8 header and IDC cable instead of mounting the shield on the back of the matrix.

Parts Needed

To follow this example, you would will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Wishlist for Matrix Clock w/ the DS1307 RTC Module Example SparkFun Wish List:

Setting Up the DS1307 RTC Module

If you have not already, solder right angle headers to the RTC module.

Make sure that you installed PJRC's DS1307RTC and Time libraries with the Teensyduino add-on. You can check by viewing the Arduino program folder where the files were installed under. In this case, it was in the “…Arduino\hardware\teensy\avr\libraries” path.

Figure 25

If it is not installed, you can run the Teensyduino add-on installer again to add the associated files. Under Libraries to Install, make sure that the checkbox is checked off for DS1307RTC and Time libraries.

Figure 26

Circuit Diagram 1

Make the following connection between the DS1307 breakout board and Teensy stacked on the SmartLED shield. If you used right angle headers on the DS1307 breakout board, you can use four M/F jumper wires to connect.

Figure 27

Hookup Table 1

Figure 28

Upload Code

In the Arduino IDE, open File > Examples > DS1307RTC > SetTime.ino. The sketch will automatically set the date and time for the RTC from the compiler once you upload. You will need to run this code if the battery was removed or the time does not match your time zone. Select the Teensy board definition with the associated COM port and click upload. To check if the clock matches your computer's time, simply open the Arduino serial monitor set at 9600 baud. You should see an output similar to the one shown below.

Copy Code
DS1307 configured Time=13:00:47, Date=Nov 12 2018

Troubleshooting: If you are receiving an output similar to the one below, check your connections or disconnect/connect the USB cable from the Teensy before opening the serial monitor again.

Copy Code
DS1307 Communication Error :-{
Please check your circuitry

MatrixClock

Now that the clock is configured, let's output the time to the 32x32 panel!

Circuit Diagram 2

Adjust the SDA and SCL wires as shown in the diagram below.

Figure 29

Hookup Table 2

Figure 30

Notice that the wires are in a different location and flipped? Well that's because the I2C pins are redefined for the SmartMatrix Shield! Make sure to move the pins and switch the order that they are connected.

Figure 31

Modifying Code

Next, open the MatrixClock.ino example by clicking on File > Examples > SmartMatrix3 > MatrixClock in the Arduino IDE. Since we are using the SmartLED shield and the 32x32 panel with 1:16 scan rate, there is only one line of code that needs to be adjusted. We just need to:

  • uncomment line “#include <SmartLEDShieldV4.h>” by removing the “//

Upload Code

Once the code has been adjusted, select correct board and COM port to upload to the Teensy 3.2. Connect the IDC cable to the SmartLED shield with the 2x8 male header pins. Then add power to the panel and Teensy to view begin viewing the time!

Figure 32

Example: Animated GIFs

Heads up! The Animated GIFs example was written for a 32x32 panel. If you are using it with a different size, you will need to either re-center or adjust the GIF size. For example, when a 32x32 GIF is displayed on a 64x64 panel, it will begin displaying from the upper left hand corner of the panel.

In this example, we will take advantage of the built-in microSD card on the Teensy 3.6 to display animated GIFs on a 32x32 panel with 1:16 scan rate.

Parts Needed

To follow this example, you would will need the following materials. You may not need everything though depending on what you have. Add it to your cart, read through the guide, and adjust the cart as necessary.

Wishlist for Animated GIFs Example SparkFun Wish List:

If you haven’t already, solder the headers on the Teensy 3.6. Then insert the development board into the SmartLED shield's socket.

Figure 33

Tip: If you want to take full advantage of the pins on the Teensy 3.5/3.6, you will need to add headers beyond the 1x14 pins along the side of a Teensy and snap off the mounting hole below pin 13.

Figure 34

Right angle headers would be better for a low profile behind the RGB LED matrix panel. You can also solder wire to the connections depending on your setup.

You may notice that there is a GitHub subtree called “AnimatedGIFs @ …” that was pulled into the SmartMatrix library's examples folder. However, the folder may not have been included when installing the library via the Arduino Library Manager. If you do not see the folder from the Arduino IDE under File > Examples > SmartMatrix3 > Animated GIFs, you will need to download and unzip the files from this repository:

GITHUB PIXELMATRIX: ANIMATED GIFS

Once the folder is unzipped, make sure that the AnimatedGIFs.ino file and all associated files are under the same folder name called “…/AnimatedGIFs” as shown in the image below.

Figure 35

Modifying Code

Open the AnimatedGIFs.ino example. Since the defaults kMatrixWidth, kMatrixHeight, and kPanelType are already set for the 32x32 panel with 1:16 scan rate, we just need to:

  • uncomment line “#include <SmartLEDShieldV4.h>” by removing the “//
  • uncomment line “//#define SD_CS BUILTIN_SDCARD” by removing the “//
  • comment next line “#define SD_CS 15” by adding the “//

Upload Code

Once the code has been adjusted, select correct board and COM port to upload to the Teensy 3.6.

Adding GIFs

The next step is to add the …/gifs folder into the microSD card. Remove power from the Teensy 3.6 if a microSD card was inserted in the socket. Connect to the memory card using a card adapter or microSD USB reader. Copy and paste the …/gifs folder into the root directory of the memory card.

Figure 36

Safely remove the memory card from your computer by ejecting or unmounting the microSD card. After removing the memory card from the adapter or USB reader, insert it into the built-in microSD card socket on the Teensy.

Note: Unlike certain microSD card sockets, the microSD card will not click in when inserted into the Teensy.

Stack the board on the panel's IDC connector.

Figure 37

If you have not already, add power to the panel. Then add power to the Teensy. The Teensy will begin displaying the GIFs that were included in the folder. Pretty neat!

Figure 38

Diffusing the LEDs

The animations may be hard to view as you can see on the image on the left. To help diffuse the light, a translucent material placed in the front of the panel to blend the pixels. The image on the right used a piece of white paper to blend the individual pixels. For long term installations, try using frosted acrylic as used in the Aurora project.

Figure 39

Adding MOAR GIFs

Looking for more GIFs? Try checking the GIFs provided in the Aurora project:

GITHUB PIXEL MATIX: AURORA / SD

Simply copy any file with the *.gif extension and include it in the …/gifs folder as explained earlier. The 10x weather GIFs are neat animations if you want display the current weather on a panel for your next cloud connected IoT project!

Figure 40

You can also do a custom search for 32x32 GIFs on Google.

GOOGLE IMAGE SEARCH: 32X32 ANIMATED "GIFS"

Resources and Going Further

Now that you’ve successfully got your SmartLED shield for Teensy up and running, it’s time to incorporate it into your own project!

For more information, check out the resources below:

制造商零件编号 DEV-15046
SMARTLED SHIELD V4 FOR TEENSY
SparkFun Electronics
制造商零件编号 COM-14646
ADDRESS LED MATRIX RGB
SparkFun Electronics
制造商零件编号 COM-14718
ADDRESS LED MATRIX SERIAL RGB
SparkFun Electronics
制造商零件编号 DEV-13736
TEENSY 3.2 K20 EVAL BRD
SparkFun Electronics
制造商零件编号 DEV-14057
TEENSY 3.6 W/OUT HDRS K66 EVAL
SparkFun Electronics
制造商零件编号 DEV-14058
TEENSY 3.6 W/ HDRS K66 EVAL BRD
SparkFun Electronics
制造商零件编号 DEV-14055
TEENSY 3.5 W/OUT HDRS K64 EVAL
SparkFun Electronics
制造商零件编号 DEV-14056
TEENSY 3.5 W/ HDRS K64 EVAL BRD
SparkFun Electronics
制造商零件编号 PRT-10288
ADAPT TERM BL 2POS TO 2.1MM JCK
SparkFun Electronics
制造商零件编号 BOB-12708
EVAL BOARD FOR DS1307
SparkFun Electronics
制造商零件编号 COM-13004
MICROSD USB READER
SparkFun Electronics
制造商零件编号 WLC100
SOLDERING STATION 40W 1 CH 120V
Apex Tool Group
制造商零件编号 PRT-08431
JUMPER WIRE M/M 6" 10PCS
SparkFun Electronics
制造商零件编号 PRT-09140
JUMPER WIRE M/F 6" 10PCS
SparkFun Electronics
制造商零件编号 HDR100IMP40M-G-V-TH
CONN HEADER VERT 40POS 2.54MM
Chip Quik Inc.
制造商零件编号 HDR100IMP40M-G-RA-TH
CONN HEADER R/A 40POS 2.54MM
Chip Quik Inc.
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum