[BPI-M3] BPI 8×8 LED Matrix Module and how to use

OS: BPI-M3 Ubuntu15.10 (Kernel3.4) Version: 1.0 HDMI


Step 1: Download WiringPI

$ git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git1 -b BPI_M3 $ cd BPI-WiringPi $ chmod +x ./build $ sudo ./build

Step 2 : Copy smaple code to Blue_RGB8*8.c file

$ sudo vi Blue_RGB8*8.c

Step 3 : Compile Blue_RGB8*8.c

$ gcc -o Blue_RGB88 Blue_RGB88.c -l wiringPi

Step 4: Run Blue_RGB8*8

$ sudo ./Blue_RGB8*8


Video : how to install hardware:

Video : function demo


Sample Code:

#include <stdio.h>
#include <wiringPi.h>
#include <sr595.h>

#define SPACE { \
    {0, 0, 0, 0, 0, 0, 0, 0},  \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0}, \
    {0, 0, 0, 0, 0, 0, 0, 0} \
}

#define FULL { \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1}, \
    {1, 1, 1, 1, 1, 1, 1, 1} \
}

#define H { \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}  \
}

#define E  { \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define L { \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 0, 0}, \
    {0, 1, 1, 1, 1, 1, 1, 0}  \
}

#define O { \
    {0, 0, 0, 1, 1, 0, 0, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 0, 1, 0, 0, 1, 0, 0}, \
    {0, 0, 0, 1, 1, 0, 0, 0}  \
}

#define Smile { \
	{0, 0, 1, 1, 1, 1, 0, 0}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {1, 0, 1, 0, 0, 1, 0, 1}, \
    {1, 0, 0, 0, 0, 0, 0, 1}, \
    {1, 0, 1, 0, 0, 1, 0, 1}, \
    {1, 0, 0, 1, 1, 0, 0, 1}, \
    {0, 1, 0, 0, 0, 0, 1, 0}, \
    {0, 0, 1, 1, 1, 1, 0, 0}  \
}
#define Line { \
    {1, 0, 0, 0, 0, 0, 0, 0},  \
    {0, 1, 0, 0, 0, 0, 0, 0},  \
    {0, 0, 1, 0, 0, 0, 0, 0},  \
    {0, 0, 0, 1, 0, 0, 0, 0},  \
    {0, 0, 0, 0, 1, 0, 0, 0},  \
    {0, 0, 0, 0, 0, 1, 0, 0},  \
    {0, 0, 0, 0, 0, 0, 1, 0},  \
    {0, 0, 0, 0, 0, 0, 0, 1},  \
}

int RowRed[8]={116,117,118,119,120,121,122,123};
int RowGreen[8]={108,109,110,111,112,113,114,115};
int RowBlue[8]={100,101,102,103,104,105,106,107};
int Column[8]={124,125,126,127,128,129,130,131};


void MatrixSetup()
{
	int j;
	for(j = 0; j < 32; j++)
    {
        pinMode(100 + j, OUTPUT);
    }
    for(j = 0; j < 8; j++)
    {
        digitalWrite(100 + j, 1);
    }
    for(j = 0; j < 8; j++)
    {
        digitalWrite(116 + j, 1);
    }
    for(j = 0; j < 8; j++)
    {
        digitalWrite(108 + j, 1);
    }
}
void Clear()
{
    int i;
    for(i=0;i<8;i++)
    {
        digitalWrite(RowRed[i],1);
        digitalWrite(RowGreen[i],1);
        digitalWrite(RowBlue[i],1);
        digitalWrite(Column[i],0);
    }


}
int main(int argc, char *argv[])
{
    int column, row, thisPixel;
    long long k;
    wiringPiSetup();
    sr595Setup(100, 32, 12, 14, 10);
    MatrixSetup();
    int matrix[8][8]= Smile ;
    while(1)
    {
        Clear();
        for(column=0;column<8;column++)
        {
            digitalWrite(Column[column],1);
            for(row=0;row<8;row++)
            {
                if(matrix[column][row] == 1)
                    digitalWrite(RowBlue[row],0);  // Blue color
                digitalWrite(RowBlue[row],1);      // Blue color
            }
            digitalWrite(Column[column],0);
        }
    }
}

more information:

https://bananapi.gitbooks.io/bpi-accessories/content/RGbLEDMatrixmodule.html