32x8 LED Matrix Message Display Using Bluetooth Commands from Mobile Phone

Overview:

An LED matrix is a dot matrix with a series of LED lights arranged in a grid of specified length. LED matrices come with a variety of sizes, from a simple 8x8 matrix to a large 32x32 matrix, and so on and are mostly used to display information.

This tutorial uses a 32x8 LED Matrix to display text messages using Bluetooth commands from a mobile application. The alphanumeric message will scroll from right to left and will change immediately if the user wishes to send another message through the mobile app.

 

Hardware Used:

Arduino UNO

Matrix LED Display (32x8 module)

HC-05 Bluetooth module

Breadboard

Jumper Wires

 

Software Used:

Arduino IDE

Bluetooth Terminal HC-05

 

Application Discussion

LED matrices are commonly used to display information that its user wishes to convey to its audience. They spell out their messages either through basic sentences/phrases or through symbols to get the point across quicker.

This application of the LED Matrix, specifically a 32x8 module, aims to teach you on how to display messages with it and how to do so through a Bluetooth app on your phone.

 

Matrix LED Display, 32x8 module, MAX7219

Product description:

  • A single module can drive an 8x8 dot matrix common cathode
  • Operating Voltage: 5V
  • Dimensions: 12.8X12.8X1.3cm
  • Module with input and output interfaces, support for cascading multiple modules
  • The left side of the module is where the input port is located, while the right side of the module is where the output port is located
  • When in control of a single module, simply have the input port connected to the microcontroller (e.g. Arduino)
  • When using more than one modules in cascade, the input terminals of the second module is connected to the output terminals of the first module, and so on.. 

 

HC-05 Bluetooth module

Product Description

  • Uses the CSR mainstream Bluetooth chip, Bluetooth V2.0 protocol standards.
  • Module working voltage: 3.3 V.
  • Default baudrate of 9600
  • The core module size: 28 mm x 15 mm x 2.35 mm.
  • With LED indicator light
  • Uses 150mA and 3.3V voltage regulation chip
  • VCC, GND, TXD, and RXD pins for serial communication with processor or microcontroller (MCU)
  • With "re-search connection" button (ON/OFF/WAKE pin for it, external MCU will input "High level" to enable module to re-search for nearby Bluetooth connections)
  • Can be used as master or slave
  • Input voltage: 3.3~6V

 

Hardware Setup

Actual Setup

Fritzing Diagram

Schematic Diagram

Pin Configuration

Arduino UNO pins

PIN 0 (RX)    => Bluetooth module TXD (BLUE)

PIN 1 (TX)    => Bluetooth module RXD (PURPLE)

PIN 10          => LED matrix module PIN 2 (YELLOW)

PIN 11          => LED matrix module PIN 3 (GREEN)

PIN 13          => LED matrix module PIN 1 (ORANGE)

GND 1          => Bluetooth module GND (BLACK)

GND 2          => LED matrix module PIN 4 (BLACK)

VCC             => LED PIN 5 and Bluetooth VCC (RED) (Add to Breadboard)

 

Software Setup:

The Arduino Code for the application can be downloaded here. You must also download and import the LedControl library, which is provided by wayoda and available here.

After uploading the code in Arduino, download the Bluetooth Terminal HC-05 app available in the Google Play Store (for Android) and turn on the Bluetooth function on your Android phone.

 

Open the app, search for Bluetooth connections, and select your HC-05 Bluetooth module. You can now enter text for any message that you want to display!

 

Code Breakdown:


#include <LedControl.h>

  • Imports the library LedControl to the project.

String message ="";

  • Creates an empty string to store future data for the messages received.

const int numDevices = 4;

  • Indicates the maximum number of MAX7219 modules used in the project.

const long scrollDelay = 60;

  • Scrolling speed of the message.

const unsigned char initialText[] PROGMEM ={"Open the Bluetooth app and send your message.   "};

  • Displays the initial text. After a new text is sent using your smartphone through Bluetooth, you must wait until the last text finishes scrolling before your new text will be displayed. Two spaces are added to give the message more room.

const unsigned char scrollText0[] PROGMEM ={" "};

  • Saves on to the memory of Arduino all the characters, icons and symbols to be used for the module.

void setup(){
  Serial.begin(9600);
  for (int x=0; x<numDevices; x++){
    lc.shutdown(x,false);
    lc.setIntensity(x,8);
    lc.clearDisplay(x);
    }
}
  • Starts the serial communication for the Bluetooth module
  • The MAX72XX module is in power-saving mode on startup
  • Sets the brightness of the LEDs to default value
  • Clears the display

void loop(){
  if(initial==0)
  {
    scrollMessage(initialText);
  }
 
  while(Serial.available() > 0)
    {
      message = Serial.readString();
      initial=1;
    }
  for (int i=0; i < message.length(); i++)
    {
      if (message[i] == ' ')
        {
        scrollMessage(scrollText0);
        }

  • Starts the infinite loop of the text
  • Starts scrolling the initial text
  • Stores the Bluetooth received text
  • Goes letter by letter and send the dots vector for the LEDs to the drivers

const unsigned char font5x7 [] PROGMEM = {
    B00000000,  //z
    B00000000,
    B11111000,
    B00010000,
    B00100000,
    B01000000,
    B11111000,
    6,

  • Numeric Font Matrix (Arranged as 7x font data + 1x kerning data)
  • Defines the character used for the message
  • Numbers on the end give the amount of empty space between the characters

void scrollFont() {
    for (int counter=0x20;counter<0x80;counter++){
        loadBufferLong(counter);
        delay(500);
    }
}
 
void scrollMessage(const unsigned char * messageString) {
    int counter = 0;
    int myChar=0;
    do {
        // read back a char
        myChar =  pgm_read_byte_near(messageString + counter);
        if (myChar != 0){
            loadBufferLong(myChar);
        }
        counter++;
    }
    while (myChar != 0);
}
void loadBufferLong(int ascii){
    if (ascii >= 0x20 && ascii <=0x7f){
        for (int a=0;a<7;a++){
            unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a);
            unsigned long x = bufferLong [a*2];
            x = x | c;  
            bufferLong [a*2] = x;
        }
        byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 8) + 7);
        for (byte x=0; x<count;x++){
            rotateBufferLong();
            printBufferLong();
            delay(scrollDelay);
        }
    }
}
void rotateBufferLong(){
    for (int a=0;a<7;a++){
        unsigned long x = bufferLong [a*2];
        byte b = bitRead(x,31);  
        x = x<<1;            
        bufferLong [a*2] = x; 
        x = bufferLong [a*2+1];
        x = x<<1;      
        bitWrite(x,0,b);
        bufferLong [a*2+1] = x;
    }
}
void printBufferLong(){
  for (int a=0;a<7;a++){
    unsigned long x = bufferLong [a*2+1];
    byte y = x;   
    lc.setRow(3,a,y);
    x = bufferLong [a*2]; 
    y = (x>>24);              
    lc.setRow(2,a,y);         
    y = (x>>16);            
    lc.setRow(1,a,y);  
    y = (x>>8);          
    lc.setRow(0,a,y);    
  }
}

  • Functions that send the serial data of each vector to the MAX7219 drivers
  • Scroll message, loading characters into the scroll buffer, rotating the buffer, display Buffer on LED matrix
Video Output

 

Conclusion

The 32x8 LED Matrix is a great tool for displaying messages. Once you learn the basics of Arduino, then this application of the LED Matrix will be beneficial for you in understanding how to manipulate circuits to your liking and how to do so by using mobile apps.

 

References

https://create.arduino.cc/projecthub/biharilifehacker/arduino-tutorial-led-matrix-red-32x8-256-led-0f2684

32x8 led matrixAndroidAndroid phoneArduinoArduino unoBluetoothHc-05Hc05Led matrixMatrix ledMobile app

Leave a comment

All comments are moderated before being published