Wednesday, September 12, 2018

Arduino and 8x8 LED matrix


This is the datasheet: http://www.kingbrightusa.com/images/catalog/SPEC/TC15-11SRWA.pdf
I made the table below for easily wiring. Also, the pin of the array start from 1 - 8, and 9 - 16. To determine the location of the pin, you can start wiring 2 left side, or right side pin to 3.3V and GND. According to the table below, the when we connect pin 1 and 16 together, the LED at position Row 5:Column 8 will light up.

R and C Pin on LED board Pin on Arduino
r5 1 6
r7 2 8
c2 3 11
c3 4 12
r8 5 9
c5 6 a0
r6 7 7
r3 8 4
r1 9 2
c4 10 13
c6 11 a1
r4 12 5
c1 13 10
r2 14 3
c7 15 a2
c8 16 a3

I'll talk briefly about how it works and you can try it your own.

We have a Row and a Col(column), when both Row and Col are set to 1, the LED will off, so to keep the LED on, we set Row to 1 and Col to 0 at specific location.

We're going to use for loop run from row 1 to 8 and set each row to 1
Then, we use another for loop to set each column to either 1 or 0
Finally, we reset the whole column

Using the available code, I need to fix couple things

  1. I rearrange col array from 8 to 1
  2. Set inverse for the buffer 

The code from Arduino Project Hub is clever
I've learned that to manage grids or matrix we should add all pins to constant array rows and columns such as:

const byte rows[] = {
    ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};
const byte col[] = {
  COL_1,COL_2, COL_3, COL_4, COL_5, COL_6, COL_7, COL_8
};
The code and tutorial is here: https://create.arduino.cc/projecthub/SAnwandter1/programming-8x8-led-matrix-23475a

What we can do next?
👉Control LED board with Android or Iphone using ESP82
👉Add this board to my RC car pj
👉Add MAX7219