Hi, I'm very much a beginner with Arduinos (or is that Arduini). I have a UNO and a WS2812B LCD matrix. I've got the hang of lighting the LEDs up in various ways using the FastLED library, and now I'd like to display some text. Presumably all I need is a "font" in the form of lots of predefined arrays to form each letter and number - presumably these also come in different sizes 8x8, 8x5, 7x5 etc. There seem to be all sorts of libraries around like AdaFruit GFX but I get the impression these are more complicated than I need to start with. Can anyone advise?
I don't know if this is what you want, but check out this YouTube video, Scrolling Text using a Chinese 8x32 WS2812B LED MATRIX neopixel.
The sketch it uses does use the Adafruit libraries, but the sketch itself is really quite simple.
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 9
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(204, 0, 204), matrix.Color(204, 204, 0), matrix.Color(0, 255, 255),
matrix.Color(255, 10, 127), matrix.Color(127, 0, 255), matrix.Color(0, 255, 0),
matrix.Color(255, 99, 255)};
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(40);
matrix.setTextColor(colors[0]);
}
int x = matrix.width();
int pass = 0;
void loop() {
matrix.fillScreen(0); //Turn off all the LEDs
matrix.setCursor(x, 0);
matrix.print(F("MOJO+TAHI 6-28-20"));
if( --x < -110 ) {
x = matrix.width();
if(++pass >= 8) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(33);
}
Thanks Mr Y. I'm using a 16x16 array while I wait for something better to arrive in the post, but once I'd tweaked the Adafruit_NeoMatrix constructor a bit it worked a treat. I do have a question however: I found the fonts in the Adafruit_GFX_Library folder, with all the files containing lots of arrays of font data, just as I expected, but I couldn't work out how my sketch specified which font to use. There are obviously lots to choose from, but I couldn't work out where in the code the font is specified. As a (retired) developer I like to know how these things work. Can you enlighten me?
This article may be of help.
Also, this is the documentation for the Adafruit GFX library.
Brilliant. Thanks
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.