0% found this document useful (0 votes)
35 views8 pages

25 - 8x8 LED Matrix

This document describes how to control an 8x8 LED matrix using row-column scanning with an Arduino microcontroller. It explains that the LED matrix has rows of common anodes and columns of common cathodes that can each be selectively turned on or off by setting the appropriate row high and column low. The document provides the pin connections for an 8x8 LED matrix to an Arduino and includes the code to control displaying images on the matrix by drawing each row in sequence.

Uploaded by

Minh Đăng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views8 pages

25 - 8x8 LED Matrix

This document describes how to control an 8x8 LED matrix using row-column scanning with an Arduino microcontroller. It explains that the LED matrix has rows of common anodes and columns of common cathodes that can each be selectively turned on or off by setting the appropriate row high and column low. The document provides the pin connections for an 8x8 LED matrix to an Arduino and includes the code to control displaying images on the matrix by drawing each row in sequence.

Uploaded by

Minh Đăng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Row-columm Scanning to control an 8x8 LED

Matrix
LED displays are often packaged as matrixes of LEDs arranged in rows of common
anodes and columns of common cathodes, or the reverse. Here's a typical example,
and its schematic:
These can be very useful displays. To control a matrix, you connect both its rows and
columns to your microcontroller. The columns are connected to the LEDs cathodes, so
a column needs to be LOW for any of the LEDs in that column to turn on. The rows
are connected to the LEDs anodes, so the row needs to be HIGH for an individual
LED to turn on. If the row and the column are both high or both low, no voltage flows
through the LED and it doesn’t turn on.

To control an individual LED, you set its column LOW and its row HIGH. To control
multiple LEDs in a row, you set the row HIGH, then take the column high, then set
the columns LOW or HIGH as appropriate; a LOW column will turn the
corresponding LED ON, and a HIGH column will turn it off.

Tip - Pins set to OUTPUT by use of the PinMode command are set to LOW if not
otherwise stated

Although there are pre-made LED matrices, you can also make your own matrix from
64 LEDs, using the schematic as shown above.

It doesn’t matter which pins of the microcontroller you connect the rows and columns
to, because you can assign things in software. Connected the pins in a way that makes
wiring easiest. A typical layout is shown below.

Here's a matrix of the pin connections, based on the diagram above:

Matrix pin no. Row Column Arduino pin number

1 5 - 13

2 7 - 12

3 - 2 11

4 - 3 10

5 8 - 16 (analog pin 2)

6 - 5 17 (analog pin 3)
7 6 - 18 (analog pin 4)

8 3 - 19 (analog pin 5)

9 1 - 2

10 - 4 3

11 - 6 4

12 4 - 5

13 - 1 6

14 2 - 7

15 - 7 8

16 - 8 9

Hardware Required
1. Arduino or Genuino Board
2. 8 x 8 LED Matrix
3. 2 10k ohm potentiometers
4. hook-up wires
5. breadboard

Circuit
The 16 pins of the matrix are hooked up to 16 pins of the Arduino or Genuino board.
Four of the analog pins are used as digital inputs 16 through 19. The order of the pins
is assigned in two arrays in the code.

Two potentiometers, connected to analog pins 0 and 1, control the movement of a lit
LED in the matrix.
Schematic

Code
#define ROW_1 2
#define ROW_2 7
#define ROW_3 19
#define ROW_4 5
#define ROW_5 13
#define ROW_6 18
#define ROW_7 12
#define ROW_8 16

#define COL_1 9
#define COL_2 8
#define COL_3 4
#define COL_4 17
#define COL_5 3
#define COL_6 10
#define COL_7 11
#define COL_8 6

const byte rows[] = {


ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};
const byte cols[] = {
COL_1,COL_2, COL_3, COL_4, COL_5, COL_6, COL_7, COL_8
};

// The display buffer


// It's prefilled with a smiling face (1 = ON, 0 = OFF)
// https://xantorohara.github.io/led-matrix-editor/
byte smileFace[] =
{B11000011,B10111101,B01011010,B01111110,B01011010,B01100110,B10111101,B110000
11};
byte sadFace[] =
{B11000011,B10111101,B01011010,B01111110,B01100110,B01011010,B10111101,B110000
11};

float timeCount = 0;
const int speedChange = 100;

void setup()
{
// Open serial port
Serial.begin(9600);

// Set all used pins to OUTPUT


// This is very important! If the pins are set to input
// the display will be very dim.
for (byte i = 2; i <= 13; i++)
pinMode(i, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
}

void loop() {
delay(5);
timeCount += 1;
if(timeCount < speedChange) {
drawMatrix(smileFace);
}
else if(timeCount < 2*speedChange) {
drawMatrix(sadFace);
}
else {
// back to the start
timeCount = 0;
}
}

void drawMatrix(byte data[]){


// Turn on each row in series
for (byte i = 0; i < 8; i++) {
digitalWrite(rows[i], HIGH); //initiate whole row
// Turn on each point in row
for (byte a = 0; a < 8; a++){
// if You set (~data[i] >> a) then You will have positive
digitalWrite(cols[a], (data[i] >> a) & 0x01); // initiate whole column
delayMicroseconds(100); // uncoment deley for diferent speed of
display

digitalWrite(cols[a], HIGH); // reset whole column


}
digitalWrite(rows[i], LOW); // reset whole row
// otherwise last row will intersect with next row
}
}

Symbol and characters design


The symbol and characters can be design at the following link:

https://xantorohara.github.io/led-matrix-editor/

Here are some characters are designed.

byte CLEAR[] =
{B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B111111
11};
byte EX[] =
{B11111111,B11101111,B11101111,B11101111,B11101111,B11111111,B11101111,B111111
11};
byte A[] =
{B11100111,B11000011,B10011001,B10000001,B10011001,B10011001,B10011001,B100110
01};
byte B[] =
{B10000111,B10000011,B10011011,B10000111,B10011011,B10011011,B10000011,B100001
11};
byte C[] =
{B11000011,B10000001,B10011101,B10011111,B10011111,B10011101,B10000001,B110000
11};
byte D[] =
{B10000111,B10000011,B10011001,B10011001,B10011001,B10011001,B10000011,B100001
11};
byte E[] =
{B10000011,B10000011,B10011111,B10000011,B10011111,B10011111,B10000011,B100000
11};
byte F[] =
{B10000011,B10000011,B10011111,B10000011,B10011111,B10011111,B10011111,B100111
11};
byte G[] =
{B11000011,B10000001,B10011111,B10010000,B10011001,B10011001,B10000001,B110000
11};
byte H[] =
{B10011001,B10011001,B10011001,B10000001,B10011001,B10011001,B10011001,B100110
01};
byte I[] =
{B10000001,B10000001,B11100111,B11100111,B11100111,B11100111,B10000001,B100000
01};
byte J[] =
{B10000001,B10000001,B11111001,B11111001,B11111001,B10011001,B10000001,B110000
11};
byte K[] =
{B10011101,B10011011,B10010111,B10001111,B10000111,B10010011,B10011001,B100111
00};
byte L[] =
{B10011111,B10011111,B10011111,B10011111,B10011111,B10011001,B10000001,B100000
01};
byte M[] =
{B10011100,B10001000,B10000000,B10010100,B10011100,B10011100,B10011100,B100111
00};
byte N[] =
{B10011100,B10001100,B10000100,B10010000,B10011000,B10011100,B10011100,B100111
00};
byte O[] =
{B11000011,B10000001,B10011001,B10011001,B10011001,B10011001,B10000001,B110000
11};
byte P[] =
{B10000011,B10000001,B10011001,B10011001,B10000011,B10011111,B10011111,B100111
11};
byte Q[] =
{B11000011,B10000001,B10011001,B10011001,B10011001,B10010001,B10011001,B110000
10};
byte R[] =
{B10000011,B10000001,B10011001,B10000011,B10000111,B10010011,B10011001,B100111
00};
byte S[] =
{B11000111,B10011011,B10011111,B11000111,B11100011,B11111011,B10010011,B110001
11};
byte T[] =
{B10000001,B10000001,B11100111,B11100111,B11100111,B11100111,B11100111,B111001
11};
byte U[] =
{B10011001,B10011001,B10011001,B10011001,B10011001,B10011001,B10011001,B110000
11};
byte V[] =
{B10011100,B10011100,B10011100,B10011100,B10011100,B11011101,B11101011,B111101
11};
byte W[] =
{B10011100,B10011100,B10011100,B10011100,B10011100,B10010100,B10001000,B100111
00};
byte X[] =
{B10011100,B10011100,B11001001,B11110111,B11101011,B11011001,B10011100,B100111
00};
byte Y[] =
{B10011001,B10011001,B10011001,B11011011,B11100111,B11100111,B11100111,B111001
11};
byte Z[] =
{B10000001,B10011001,B11110001,B11100011,B11001111,B10011101,B10000001,B100000
01};

You might also like