Moving Beyond the Ordinary With the Qwiic Alphanumeric Display

Pages
Contributors: ROB-24601
Favorited Favorite 1

Going Beyond the Basics

Our shift function is a fast and super-simple way to scroll text, but the length of the text is limited to four characters. (More if you’re using multiple displays, but we’ll talk about that a little later on.) So, what can you do if you want to scroll a text string that’s longer than the number of display digits you have. We just need to get a little creative with our coding.

Example - Moving text the hard way Suppose I want to try the scrolling example, but I’m lactose intolerant. I want to scroll “soy milk”, but my display is only four characters. For this, we can use a little creative manual character shifting. Take a look at the code below, and you’ll see how the eight characters (I’m including the space between the two words) make their way past the four available spaces.

/*******************************************************************************************
 * This demo shows how to manually scroll a word or words longer than four characters
 * across a digit alphanumeric display.
 * 
 * Rob Reynolds @ SparkFun Electronics
 * Original Creation Date: October 16, 2024
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board from SparkFun! https://www.sparkfun.com/products/19297
 * 
 * This code is Beerware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board to computer using micro-B USB cable.
 * Attach Qwiic Alphanumeric board to Red Board using Qwiic cable.
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <Wire.h>

#include <SparkFun_Alphanumeric_Display.h>  //Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_Alphanumeric_Display by SparkFun
HT16K33 display;

void setup()
{
  Serial.begin(115200);
  Serial.println("SparkFun Qwiic Alphanumeric - Example 2: Turn On One Segment");
  Wire.begin(); //Join I2C bus


if (display.begin() == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while(1);
  }

  Serial.println("Display acknowledged.");
  delay(2000);

}

void loop()
{
  // Scroll SOY MILK past the 4 available character displays
  display.clear();
  display.print("SOY ");
  delay(1000);
  display.clear();
  display.print("OY M");
  delay(300);
  display.clear();
  display.print("Y MI");
  delay(300);
  display.clear();
  display.print(" MIL");
  delay(300);
  display.clear();
  display.print("MILK");
  delay(300);
  display.clear();
  display.print("ILK");
  delay(300);
  display.clear();
  display.print("LK");
  delay(300);
  display.clear();
  display.print("K");
  delay(300);
  display.clear();
  delay(5000);

}

Earlier, I mentioned the possibility of using multiple displays. This takes a little bit of work on the front end, but after that, using four displays is just as easy as using one.

On the rear of the display board, you’ll find a pair of jumpers labeled A0 and A1. These jumpers will allow you to change the I2C address, giving you four options.

alt text


We’ve made linking and using multiple displays incredibly simple. There are just a couple of things you need to keep in mind. In your setup(), you will, as usual, check to make sure that your I2C peripheral (in this case your Alphanumeric Display) acknowledges, like this:

if (display.begin() == false)

When using multiple displays, you simply verify that all of them acknowledge, like this:

 if (display.begin(0x70, 0x71, 0x72, 0x73) == false)

The big thing the remember here is that when daisy-chaining your displays, they do not need to be connected in numeric order. However, the order in which you verify them in your code must match their physical order, Therefore, if you are using four displays, each of a different color, once you’ve given each its own unique I2C address, you can place the colors in any order you want. Just make sure that you match their I2C address order with the order in which you verify them in your code, something like this:

if (display.begin(0x73, 0x71, 0x70, 0x72) == false) // This is perfectly acceptable

alt text
But why stop at just two Alphanumeric Displays? By changing the I2C addresses, you can daisy-chain up to four displays at once!

WARNING: TECHNICAL (BUT IMPORTANT) STUFF: When using multiple I2C devices all containing built-in pull up resistors, the parallel equivalent resistance will often create too strong of a pull up for the bus to operate. A good rule of thumb is, if you’re using multiple I2C boards, you should disable all but one pair of pull up resistors. These pull up resistors can be removed by cutting the traces of the I2C jumpers, as highlighted in the image below.

alt text
When using multiple I2C devices, you may need to cut the trace for the I2C resistors on one of your boards.