Professional Documents
Culture Documents
Datsheet Max7219
1. ต่อวงจรตามรูป
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 1/7
8/12/2019 23-max7219-ledcontroller - ePlearn
2.ติดตัง library max7219 ลงใน libraries floder ของ sketch โดยดาวน์โหลด LedControlMS.rar จาก อินเตอร์เนทหรือจากไฟล์ด ้านล่าง
สําหรับผู ้ทียังติดตังไม่เป็ นให ้ทําตามขันตอน 2.1-2.4
การติดตัง library max7219 ให ้ Arduino มองเห็น
2.1 ดาวน์โหลด LedControlMS.rar จาก ทีนี
2.2 ขยายไฟล์ แล ้วนํ าไปวางที โฟล์เดอร์ libraries ใน sketch
2.3 ปิ ดโปรแกรม Arduino แล ้วเปิ ดใหม่
2.4 ตรวจว่าเห็น library โดยใช ้เมนูไฟล์ แล ้วเลือก example จะต ้องพบกลุม
่ ตัวอย่าง LedControlMS ตามรูป
3. เขียนโปรแกรม
โปรแกรมที 1
-----------------------------------------------------------------------------------------------------------
#include "LedControlMS.h"
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD (CS)
We have only a single MAX72XX.
*/
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
/* Set the brightness to a low value */
lc.setIntensity(0,0);
/* and clear the display */
lc.clearDisplay(0);
delay(100);
lc.clearAll();
lc.setRow(0, 0, 0xff);
lc.setRow(0, 1, 0xfe);
lc.setRow(0, 2, 0xfc);
lc.setRow(0, 3, 0xf8);
lc.setRow(0, 4, 0xf0);
lc.setRow(0, 5, 0xe0);
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 2/7
8/12/2019 23-max7219-ledcontroller - ePlearn
lc.setRow(0, 6, 0xc0);
lc.setRow(0, 7, 0x80);
}
void loop(){
}
-----------------------------------------------------------------------------------------------------------
อธิบายความหมาย
value ค่าทีใช ้กําหนดการติดดับของ LED แต่ละดวงในแถวนัน ถ ้าให ้ เป็ น 1 จะทําให ้ LED ติด ถ ้าให ้เป็ น 0 จะทําให ้ LED ดับ
โดยนับบิต ที 0 ถึง 7 จากบนลงล่าง
ดังนันค่าตามโปรแกรมจะได ้ รูปเป็ น
ั
ปรับปรุงโปรแกรม ทําเป็ นฟั งก์ชน
โปรแกรมที 2
-----------------------------------------------------------------------------------------------------------
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 3/7
8/12/2019 23-max7219-ledcontroller - ePlearn
#include "LedControlMS.h"
#define NBR_MTX 1
// LedControl(DIN,CLK,CS number);
LedControl lc=LedControl(12,11,10, NBR_MTX);
void setup() {
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup,we have to do a wakeup call
lc.setIntensity(0,0); //Set the brightness to a low value
lc.clearDisplay(0); // and clear the display
delay(100);
lc.clearAll();
display(pat1);
}
void loop(){
}
-----------------------------------------------------------------------------------------------------------
ใช ้ฟั งก์ชน
ั Display แสดงภาพเคลือนไหว โดยใช ้ภาพหลายภาพ
ไฟล์_000.mp4
โปรแกรมที 3
-----------------------------------------------------------------------------------------------------------
#include "LedControlMS.h"
#define NBR_MTX 1
// LedControl(DIN,CLK,CS number);
LedControl lc=LedControl(12,11,10, NBR_MTX);
void setup() {
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup,we have to do a wakeup call
lc.setIntensity(0,0); //Set the brightness to a low value
lc.clearDisplay(0); // and clear the display
delay(100);
lc.clearAll();
}
void loop(){
for (int j=0; j < 8; j++){
display(cir1);
delay(200);
display(cir2);
delay(200);
display(cir3);
delay(200);
display(cir4);
delay(200);
display(cir5);
delay(200);
display(cir6);
delay(200);
display(cir7);
delay(200);
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 4/7
8/12/2019 23-max7219-ledcontroller - ePlearn
display(cir8);
delay(200);
}
}
---------------------------------------------------------------------------
เขียนอีกแบบให ้สันและกระชับขึน max7219-fn-test-5-2.ino
#include "LedControlMS.h"
#define NBR_MTX 1
// LedControl(DIN,CLK,CS number);
LedControl lc=LedControl(12,11,10, NBR_MTX);
void setup() {
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup,we have to do a wakeup call
lc.setIntensity(0,0); //Set the brightness to a low value
lc.clearDisplay(0); // and clear the display
delay(100);
lc.clearAll();
}
void loop(){
for (int j=0; j < 8; j++){
display(cir+8*j);
delay(200);
}
}
-----------------------------------------------------------------------------------------------------------
ใช ้ฟั งก์ชน
ั Display แสดงภาพเคลือนไหว แบบใช ้ภาพเดียว ใช ้วิธเี ลือนภาพ
ไฟล์_001.mp4
โปรแกรมที 4
-----------------------------------------------------------------------------------------------------------
#include "LedControlMS.h"
#define NBR_MTX 1
// LedControl(DIN,CLK,CS number);
LedControl lc=LedControl(12,11,10, NBR_MTX);
void setup() {
lc.shutdown(0,false); //The MAX72XX is in power-saving mode on startup,we have to do a wakeup call
lc.setIntensity(0,0); //Set the brightness to a low value
lc.clearDisplay(0); // and clear the display
delay(100);
lc.clearAll();
}
void loop(){
for (int j=0; j < 18; j++){
display(arrow+j);
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 5/7
8/12/2019 23-max7219-ledcontroller - ePlearn
delay(200);
}
}
-----------------------------------------------------------------------------------------------------------
สําหร ับผูท
้ แปลแล้
ี ว Error ให้ทดลองแปล ไฟล์ ในโปรแกรมที 4 max7219-fn-test-4.ino ด้านล่างนี
-----------------------------------------------------------------------------------------------------------
โปรแกรมที 4
ใช ้ฟั งก์ชน
ั displayChar ของ ไลบรารี แสดงเลข 0 ถึง 9
ั จะแสดงตัวอักษรอะไรได ้บ ้าง ดูได ้จากตัวแปร const static byte alphabetBitmap[41][6] ในไฟล์ LedControlMS.h ทีอยูใ่ นโฟล์เดอร์
สําหรับฟั งก์ชนนี
\Arduino\libraries\LedControlMS
-----------------------------------------------------------------------------------------------------------
#include "LedControlMS.h"
void setup() {
lc.shutdown(0,false); // do a wakeup call
lc.setIntensity(0,1); // Set the brightness to a low value
lc.clearDisplay(0); // clear the display
delay(100);
}
void loop(){
for (int j=0; j <= 9; j++){
lc.displayChar(0, j);
delay(400);
}
}
-----------------------------------------------------------------------------------------------------------
โปรแกรมที 5
ใช ้ฟั งก์ชน
ั displayChar ของ ไลบรารี แสดงตัวอักษร A ถึง Z
ควรศึกษาวิธก ี ารอ ้างอิง Address .ในตัวแปร Array alphabetBitmap[41][6]
ความหมายของ ('A'-0x41)+(15+j)
เนืองจาก
ดังนันเพือต ้องการให ้การสังพิมพ์ด ้วยการใช ้รหัส ASCII จึงปรับให ้ค่า เช่นถ ้าต ้องการแสดงตัว 'T' ก็ใช ้คําสัง
lc.displayChar(0, ('T'-0x41+15));
หรือบวกลบกันก่อน
-0x41+ 15 = -65+15 = -50
lc.displayChar(0, ('T'-50))
-----------------------------------------------------------------------------------------------------------
#include "LedControlMS.h"
void setup() {
lc.shutdown(0,false); // do a wakeup call
lc.setIntensity(0,1); // Set the brightness to a low value
lc.clearDisplay(0); // clear the display
delay(100);
}
void loop(){
for (int j=0; j < 26; j++){
lc.displayChar(0, ('A'-0x41)+(15+j));
delay(400);
}
}
-----------------------------------------------------------------------------------------------------------
Č
ċ LedControlMS.rar (9k) Daddy Moon, Feb 7, 2017, 11:25 AM v.1 ď
Ċ MAX7219-MAX7221.pdf (491k) Narong Buabthong, Jan 16, 2018, 10:49 AM v.1 ď
ċ max7219-fn-test-4.ino (1k) Daddy Moon, Feb 9, 2017, 10:49 PM v.1 ď
ċ max7219-fn-test-5-2.ino (1k) Daddy Moon, Feb 10, 2017, 9:00 AM v.1 ď
Comments
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 6/7
8/12/2019 23-max7219-ledcontroller - ePlearn
Sign in | Recent Site Activity | Report Abuse | Print Page | Powered By Google Sites
https://sites.google.com/site/eplearn/arduino-project/23-max7219-ledcontroller 7/7