Learn Coding With Arduino IDE - 8×8 LED Matrix
Learn Coding With Arduino IDE - 8×8 LED Matrix
com
Login
Home All Category Contact us Clearance DEAL! Join us
Location: Home » OSOYOO Hardware Programming Learning Kit » OSOYOO Advanced Hardware Programming Learning Kit » Learn Coding with Arduino IDE– 8×8 LED matrix
NOTE: ALL OSOYOO PRODUCTS FOR ARDUINO ARE THIRD PARTY BOARD WHICH IS FULLY COMPATITAB
ARDUINO
CONTENT
1. Introduction
2. Preparations
Hardware
Software
3. About the 8×8 LED Matrix
4. Examples
Lights up an LED on the 8X8 matrix
Circuit Diagram
Upload Sketch
Running Result
Heart Blinking on the 8X8 matrix
Circuit Diagram
Code Program
Running Result
Row-columm Scanning to control an 8×8 LED Matrix
Circuit Diagram
Code Program
Introduction
LED displays are often packaged as matrixes of LEDs arranged in rows of common anodes and columns of common cathode
the reverse.They can be used to display almost anything. Most modern LED sign boards uses various types of matrix boards
controllers. In this lesson we are going to interface a single color 8×8 LED matrix with Arduin and display a few characters to
experience its charm from the beginning.
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 1/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
Preparations
HARDWARE
Osoyoo UNO Board (Fully compatible with Arduino UNO rev.3) x 1
8×8 LED Matrix x 1
10k ohm Potentiometer x2
M/M Jumpers
Breadboard x 2
USB Cable x 1
PC x 1
SOFTWARE
Arduino IDE (version 1.6.4+)
8×8 matrix consists of 64 dots or pixels. There is a LED for each pixel and these LEDs are connected to total of 16 pins.
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 2/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
Generally, there are two types of dot matrix – common cathode and common anode. They look almost the same in appearan
usually there will be labels for easy recognition. The one with a label ending with AX is a common cathode dot matrix and tha
BXis a common anode one. See the figure below for how they look like. So the pins are distributed at the two ends of the ma
Pins at one end (usually the label side) are 1-8 from left to right, when at the opposite they are 9-16 from right to left.
You can identify the pin out diagram of it using the following figure.
Below is the internal structure. You can see that in the common anode dot matrix, ROW is the anode of LED and COL is the
while the situation in the common cathode one is opposite. Though for both types, the columns are the pin 13, 3, 4, 10, 6, 11
16 and rows are the pin 9, 14, 8, 12, 1, 7, 2, and 5 in the dot matrix.
If you want to turn on all the LEDs at the first rTo light up the first LED on the upper left corner, you need to set pin 9 as high l
and pin 13 as low level in the common anode dot matrix; for a common cathode one, set pin 13 as high and pin 9 as low. ow,
common cathode dot matrix, set pin 13 as low level and ROW 9, 14, 8, 12, 1, 7, 2, and 5 as high level. In a common anode o
pin 13 as high level and those rows as low level. See the figure below for better understanding.
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 3/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
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
Note:
It doesn’t matter which pins of the microcontroller you connect the rows and columns to, because you can assign things in so
Connected the pins in a way that makes wiring easiest. We have 64 supply combinations, and doing it manually is practically
impossible. This is why Arduin is interfaced with the 8×8 matrix.
Examples
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 4/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
Circuit Diagram
To light up the first LED on the upper left corner, you need to set pin 9 as high level and pin 13 as low level in the common an
matrix; for a common cathode one, set pin 13 as high and pin 9 as low.
Upload Sketch
After above operations are completed, connect the board to your computer using the USB cable. The green power LED (labe
PWR) should go on.
Code Program
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 5/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
digitalWrite(pin3,HIGH);
digitalWrite(pin11,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pin11,LOW);//set the pin11 low,led will be turned on
delay(200);
digitalWrite(pin11,HIGH);//set the pin 11 high,led will be turned off。
delay(200);
}
Open the Arduino IDE and select corresponding board type and port type for your board. After compile this sketch, simply clic
“Upload” button in the environment. Wait a few seconds – you should see the RX and TX leds on the board flashing. If the up
successful, the message “Done uploading.” will appear in the status bar.
Running Result
A few seconds after the upload finishes, you should now see the first LED on the upper left corner will blink:
Since the wiring of this experiment is a little complicated, we need to do it step by step.
Circuit Diagram
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 6/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
Code Program
Below is my code, you can download it here, note that I used the code from the Tutorials to work out how to get everything w
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 7/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
0,1,1,1,1,1,1,0,
0,0,1,1,1,1,0,0,
0,0,0,1,1,0,0,0,
0,0,0,0,0,0,0,0,
};
void setup()
{
// iterate over the pins:
for(int i = 0;i<8;i++)
// initialize the output pins:
{
pinMode(R[i],OUTPUT);
pinMode(C[i],OUTPUT);
}
}
void loop()
{
for(int i = 0 ; i < 100 ; i++) //Loop display 100 times
{
Display(biglove); //Display the "Big Heart"
}
for(int i = 0 ; i < 50 ; i++) //Loop display 50 times
{
Display(smalllove); //Display the "small Heart"
}
}
digitalWrite(C[i],HIGH);
}
}
Running Result
A few seconds after the upload finishes, you should now see a heart blink on the 8×8 LED matrix as below:
Circuit Diagram
Code Program
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 9/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
// cursor position:
int x = 5;
int y = 5;
void setup() {
// initialize the I/O pins as outputs
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], HIGH);
}
void loop() {
// read input:
readSensors();
void readSensors() {
// turn off the last position:
pixels[x][y] = HIGH;
// read the sensors for X and Y values:
x = 7 - map(analogRead(A0), 0, 1023, 0, 7);
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 10/11
16/11/23, 1:46 Learn Coding with Arduino IDE– 8×8 LED matrix « osoyoo.com
void refreshScreen() {
// iterate over the rows (anodes):
for (int thisRow = 0; thisRow < 8; thisRow++) {
// take the row pin (anode) high:
digitalWrite(row[thisRow], HIGH);
// iterate over the cols (cathodes):
for (int thisCol = 0; thisCol < 8; thisCol++) {
// get the state of the current pixel;
int thisPixel = pixels[thisRow][thisCol];
// when the row is HIGH and the col is LOW,
// the LED where they meet turns on:
digitalWrite(col[thisCol], thisPixel);
// turn the pixel off:
if (thisPixel == LOW) {
digitalWrite(col[thisCol], HIGH);
}
}
// take the row pin low to turn off the whole row:
digitalWrite(row[thisRow], LOW);
}
}
https://osoyoo.com/2017/07/15/8x8-led-matrix/ 11/11