แบบ 1 แถว แถวละ 1 ชุด (1 x 1)
โมดูล LED 3mmDot Matrix 8x8 ดวง ขนาดจอ เส้นทะแยงมุม 40x40 มิลลิเมตร สามารถใช้งานเดี่ยว ๆ หรือนำมาเรียงต่อกันเพื่อทำไฟวิ่งแสดงข้อความได้ ใช่ง่าย มีตัวอย่างและโคดการใช้งาน
วิธีการต่ออุปกรณ์ สอนใช้งาน Arduino LED Matrix Driver MAX7219 แสงผลตัวเลข ตัวอักษร
Arduino -> LED Matrix Driver MAX7219
- 5V -> Vcc
- GND -> GND
- ขา11 -> DIN
- ขา10 -> CS
- ขา13 -> CLK
โหลด Library สอนใช้งาน Arduino LED Matrix Driver MAX7219 แสงผลตัวเลข ตัวอักษร
ต่ออุปกรณ์ตามรูปข้างบน แล้ว อัพโหลดโค้ดด้านล่าง ลงบอร์ด Arduino
1
// Demo of MAX7219_Dot_Matrix library - sideways scrolling
3
// Date: 2 October 2015
5
// Scrolls a pixel at a time.
8
#include <bitBangedSPI.h>
9
#include <MAX7219_Dot_Matrix.h>
10
const byte chips = 12;
12
// 12 chips (display modules), hardware SPI with load on D10
13
MAX7219_Dot_Matrix display (chips, 10); // Chips / LOAD
15
const char message [] = "www.arduitronics.com 123456";
22
unsigned long lastMoved = 0;
23
unsigned long MOVE_INTERVAL = 20; // mS
28
display.sendSmooth (message, messageOffset);
30
// next time show one pixel onwards
31
if (messageOffset++ >= (int) (strlen (message) * 8))
32
messageOffset = - chips * 8;
33
} // end of updateDisplay
38
// update display if time is up
39
if (millis () - lastMoved >= MOVE_INTERVAL)
42
lastMoved = millis ();
45
// do other stuff here
หรือ
วิธีการต่อใช้งาน Arduino LED Matrix MAX7219
Arduino -> LED Matrix MAX7219
- 5V -> VCC
- GND -> GND
- pin 12 - DataIn
- pin 11 - CLK
- pin 10 - CS
โหลด Library LED Matrix MAX7219 ติดตั้งลง Arduino IDE
http://www.mediafire.com/file/x6ett4lgs940d29/LedControl-master.zip/file
1
//We always have to include the library
2
#include "LedControl.h"
5
Now we need a LedControl to work with.
6
***** These pin numbers will probably not work with your hardware *****
7
pin 12 is connected to the DataIn
8
pin 11 is connected to the CLK
9
pin 10 is connected to LOAD
10
We have only a single MAX72XX.
12
LedControl lc=LedControl(12,11,10,1);
14
/* we always wait a bit between updates of the display */
15
unsigned long delaytime=100;
19
The MAX72XX is in power-saving mode on startup,
20
we have to do a wakeup call
23
/* Set the brightness to a medium values */
25
/* and clear the display */
30
This method will display the characters for the
31
word "Arduino" one after the other on the matrix.
32
(you need at least 5x7 leds to see the whole chars)
34
void writeArduinoOnMatrix() {
35
/* here is the data for the characters */
36
byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
37
byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
38
byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
39
byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
40
byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
41
byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
42
byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};
44
/* now display them one by one with a small delay */
96
This function lights up a some Leds in a row.
97
The pattern will be repeated on every row.
98
The pattern will blink along with the row-number.
99
row number 4 (index==3) will blink 4 times etc.
102
for(int row=0;row<8;row++) {
104
lc.setRow(0,row,B10100000);
106
lc.setRow(0,row,(byte)0);
107
for(int i=0;i<row;i++) {
109
lc.setRow(0,row,B10100000);
111
lc.setRow(0,row,(byte)0);
117
This function lights up a some Leds in a column.
118
The pattern will be repeated on every column.
119
The pattern will blink along with the column-number.
120
column number 4 (index==3) will blink 4 times etc.
123
for(int col=0;col<8;col++) {
125
lc.setColumn(0,col,B10100000);
127
lc.setColumn(0,col,(byte)0);
128
for(int i=0;i<col;i++) {
130
lc.setColumn(0,col,B10100000);
132
lc.setColumn(0,col,(byte)0);
138
This function will light up every Led on the matrix.
139
The led will blink along with the row-number.
140
row number 4 (index==3) will blink 4 times etc.
143
for(int row=0;row<8;row++) {
144
for(int col=0;col<8;col++) {
146
lc.setLed(0,row,col,true);
148
for(int i=0;i<col;i++) {
149
lc.setLed(0,row,col,false);
151
lc.setLed(0,row,col,true);
159
writeArduinoOnMatrix();