Bah Humbug Tree
- 2 minutes read - 296 wordsToday I finally go around to putting up the Christmas tree in my office (the main tree went up in November after a bribe of mince pies). I was gifted some rude tree decorations a few Christmases ago, and got myself a nice black Christmas tree to go with my grinchy feelings, topped with a black Santa hat.
Last year I found a MAX72 LCD matrix display and set about turning it into a tree decoration to display some festive messages. As ever, Arduino libraries make it really simple. For a Uno/Nano use the following pins:
- VCC - Vin (this draws straight from the power supply as not to overload the Arduino’s power regulator, so use a 5V supply)
- GND - Gnd
- DIN - Digital pin 11
- CD - Digital pin 3 (can be changed in code)
- CLK - Digital pin 13
The code is pretty straight forward too:
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 3
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup() {
myDisplay.begin();
myDisplay.setIntensity(10);
myDisplay.displayClear();
const char* s = "Big old heap allocation for displayed string, well as big as you can get away with on an Arduino...";
myDisplay.displayScroll(s, PA_CENTER, PA_SCROLL_LEFT, 40);
}
void loop() {
if (myDisplay.displayAnimate()) {
myDisplay.displayReset();
}
}
Here’s a quick summary of the code:
- Includes for the libraries we are using
- Setting up the correct hardware (I have 4 modules and used pin 3 for the chip select pin)
- Call begin on the display, set the desired brightness, clear any junk that appears during power on
- Create a char pointer to hold the scrolling message (beware small Arduino program and RAM sizes)
- Set the display direction and speed
- The loop constantly runs the full animation, clears the screen then resets
