How to use the MAX7219 LED Matrix for Arduino
How to use the MAX7219 LED Matrix for Arduino
INTRODUCTION
Light-emitting diodes (LEDs) arranged in a matrix form with the same power source are known as an LED Matrix. The LEDs are arranged in the form of rows and columns and the MAX7219 matrix consists of eight rows and eight columns having 64 LEDs in total.
APPLICATIONS
Its applications include signboards and displays. Multiple LED matrixes can be combined into a larger screen to display more information.
WIRING DIAGRAM
VCC – 5V
GND - GND
DIN – Digital Pin 12
CLK – Digital Pin 11
CS – Digital Pin 10
LED Matrix in the diagram below looks a little different but connections are as follows: VCC to VCC, GND to GND, DIN to 12, CLK to 11 and CS to 10.
(Note: Download the required library and follow these steps.)
- Download LED Control library here
- https://github.com/wayoda/LedControl
- Rename the folder to name without “-master” and put the folder in “arduino/libraries”.
- Here’s a guide for installing and using libraries
https://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use/arduino-libraries
CODE
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1); unsigned long delaytime=100; void setup() { lc.shutdown(0,false); /* Set the brightness to a medium values */ lc.setIntensity(0,8); /* and clear the display */ lc.clearDisplay(0); } void writeFunnyFace() { /* here is the data for the characters */ byte a[8]={B00000000,B01100110,B01100110,B00000000,B00011000,B00011000,B10000001,B01111110}; lc.setRow(0,0,a[0]); lc.setRow(0,1,a[1]); lc.setRow(0,2,a[2]); lc.setRow(0,3,a[3]); lc.setRow(0,4,a[4]); lc.setRow(0,5,a[5]); lc.setRow(0,6,a[6]); lc.setRow(0,7,a[7]); lc.setRow(0,8,a[8]); } void loop() { writeFunnyFace(); }
END RESULT
The LED matrix will display a funny face.
ADDITIONAL RESOURCES
https://www.electronicshub.org/arduino-led-matrix/