Saturday 6 April 2024

Arduino and 8x8x4 Matrix display Interfacing

 

Interfacing 8x8x4 Matrix display with Arduino




GENERIC MODULE: 

Use #define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW in Arduino code

FC-16 Module:
Use #define HARDWARE_TYPE MD_MAX72XX::FC16_HW in Arduino code


Libraries: Two libraries are needed.

(1) MD_MAX72XX by majicDesigns


(2) MD_Parola by majicDesigns



Code 1: Normal Display




#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 4
#define CS_PIN 8
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup() {
  // Intialize the object
  myDisplay.begin();
  // Set the intensity (brightness) of the display (0-15)
  myDisplay.setIntensity(1);
}

void loop() {
  // Clear the display
  myDisplay.displayClear();
  delay(2000);
  
  myDisplay.setTextAlignment(PA_LEFT);
  myDisplay.print("CST");
  delay(3000);
  
  myDisplay.setTextAlignment(PA_CENTER);
  myDisplay.print("CST");
  delay(3000);
  myDisplay.setTextAlignment(PA_RIGHT);
  myDisplay.print("CST");
  delay(3000);
  myDisplay.setTextAlignment(PA_CENTER);
  myDisplay.setInvert(true);
  myDisplay.print("CST");
  delay(3000);
  myDisplay.setInvert(false);
  myDisplay.print(1234);
  delay(3000);
}

Code 2: Scrolling Display:




#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Uncomment according to your hardware type
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
//#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
// Defining size, and output pins
#define MAX_DEVICES 4
#define CS_PIN 8
// Create a new instance of the MD_Parola class with hardware SPI connection
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup() {
  // Intialize the object
  myDisplay.begin();
  // Set the intensity (brightness) of the display (0-15)
  myDisplay.setIntensity(2);
  // Clear the display
  myDisplay.displayClear();
   myDisplay.displayScroll("* csTechomation *", PA_CENTER, PA_SCROLL_LEFT, 100);
}

void loop() {  
  if (myDisplay.displayAnimate()) {
    myDisplay.displayReset();
  } 
}

No comments:

Post a Comment