Giới thiệu
LED MATRIX 8×8 đơn giản chỉ là 64 con LED được sắp xếp với nhau theo dạng ma trận, thành 8 hàng và 8 cột, tức là 16 chân. Vì mỗi loại LED MATRIX có sơ đồ chân riêng nên các bạn hãy tra cứu datasheet của nó để có thể lắp mạch chính xác nhé. LED matrix 8×8 có dòng hoạt động thấp, độ tương phản màu sắc và tính đồng nhất tốt.




Code Arduino Nano với Led Matrix 8×8
Link tải Code + Mô phỏng Altium: https://drive.google.com/file/d/1yv-yF5ZbP4NMBDBd4iKg8zkLNjahvmxc/view
Mô phỏng Proteus

Để mô phỏng Arduino Nano cũng như các dòng Arduino khác, các bạn cần cài đặt thư viện Arduino trên Proteus. Lý do cần cài đặt thêm thư viện này vì mặc định trong Proteus không có hỗ trợ thư viện Arduino. Các bạn tải thư viện tại https://drive.google.com/drive/folders/1BqhxNNMRMR_dCIG2z9BlfJRGd5R20vQY?usp=sharing và làm như sau:
Sau khi tải về giải nén, lưu ý mình đã up nhiều thư viện từ nhiều nguồn khác nhau (ở đây viết về Arduino Library for Proteus.rar) . Chép file ArduinoTEP.IDX và ArduinoTEP.LIB vào thư mục Library của Proteus (C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY). Nếu đang mở Proteus thì tắt và khởi động lại phần mềm. Trong giao diện Pick Devices, search từ khóa “Arduino” sẽ thấy danh sách board Arduino. Bộ thư viện Arduino Library for Proteus.rar hỗ trợ:
- Arduino Uno R3
- Arduino Mega 2560
- Arduino Mega 1280
- Arduino Nano
- Arduino Mini
- Arduino Pro Mini

Tạo file Hex cho Arduino IDE
Để chạy được mô phỏng trên Proteus cho Arduino sử dụng Arduino IDE, chúng ta cần tạo file HEX, các bước nhưu sau:
Bước 1: Chuẩn bị phần mềm Arduino IDE, tạo sẵn 1 project đơn giản, build và kiểm tra lỗi
Bước 2: Vào File -> Preferences

Bước 3: Tick chọn Complation, sau đó ấn “OK” để kết thúc cài đặt

Bước 4: Build lại project một lần nữa, quan sát ở cửa sổ phía dưới thấy xuất hiện đường link chứa file .hex vừa xuất ra

Bước 5: Dựa vào đường link ở trên, bạn tìm được file .hex vừa được xuất ra

Trong trường hợp bạn muốn tự tạo thư mục riêng để lưu file Hex, các bạn có thẻ làm như sau:
Cũng tương tự như trên:
Cũng tại IDE bạn Click vào File – Preferences, sẽ xuất hiện hộp thoại Preferences, tại đây bạn tick vào ô vuông compilation, sau đó ấn OK.
Với các phiên bản từ Arduino 1.6.x đường dẫn như trong bài cũng dẫn đến file preferences.txt, nhưng file đó không chỉnh sửa được (trong đó có ghi và hướng dẫn đến file preferences khác chỉnh sửa được cho các hệ điều hành khác nhau). Như bản 1.6.5 mình dùng thì là C:\Users\Tên người dùng\AppData\Roaming\Arduino15 và làm như trong bài (Lưu ý: Trước khi chỉnh sửa thì phải tắt Arduino IDE đi, nếu không tìm thấy AppData bật chọn hiện file ẩn). Cho chắc chắn nhất nên tìm ở đâu, trong Arduino IDE bạn vào File => Preferences sẽ tìm thấy đường dẫn ở cuối cửa sổ.
Mở tập tin C:\…..preferences.txt bằng Notepad hoặc Notepad++
Thêm dòng lệnh sau vào cuối file preferences.txt: build.path = <path> (<path> là đường dẫn đến thư mục mà bạn muốn chứa file hex sau khi Arduino hoàn tất quá trình biên dịch). Ví dụ: build.path=C:\Users\ABC\Documents\Arduino\HEX ARDUINO
Sau đó bạn nhớ ấn Ctr + S để Save lại. Bạn mở lại Arduino IDE và biên dịch để tạo file HEX cho mô phỏng proteus.
Code trên Arduino IDE:

Các bạn nhớ chọn Tools => Board => Arduino Nano trước khi biên dịch nhé. Để add file header, file source cho project, các bạn chọn Sketch => Add File => Chọn đến file .h hoặc .c bạn muốn thêm vào project.

Main:
#include "Function.h"
void setup() {
// Serial.begin(9600);
for (byte i = 4; i <= 13; i++)
pinMode(i, OUTPUT);
for (byte i = 0; i < 4; i++)
pinMode(i, INPUT_PULLUP);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
pinMode(A4, OUTPUT);
pinMode(A5, OUTPUT);
drawScreen(TEST);
drawScreen(TEST);
}
void loop() {
if (NutDau == Push) { //Neu Nhan Nut Dau se nhay vao mode Nut Dau
while (NutDau == Push);
id = 1;
Nut_Nut_Dau(default_time);
}
else if (NutGiua == Push) { //Neu Nhan Nut Giua se nhay vao mode Nut Giua
while (NutGiua == Push);
id = 0;
Nut_Nut_Giua(default_time);
}
else if (NutKeCuoi == Push) { //Neu Nhan Nut Ke Cuoi khong giu qua 3s se nhay vao mode Nut Ke Cuoi
while (NutKeCuoi == Push) { //Neu Nhan va Giu Nut Ke Cuoi qua 3s se nhay vao Mode Set Time
if (Check_Nhan_Giu_Nut == 6) //LUU Y KHI SET TIME VOI CHU MAC DINH SE CO NUT !!!! BACKKKKK !!!!!
break;
Check_Nhan_Giu_Nut++;
delay(100);
}
while (NutKeCuoi == Push && Check_Nhan_Giu_Nut == 6) {
drawScreen(TimeMenu);
Checkback = 5;
}
while (Check_Nhan_Giu_Nut > 5) {
drawScreen(TimeMenu); //Hien thi ba muc Time mac dinh cho nguoi dung chon
if (NutDau == Push) { //Neu nhan NutDau se la muc nhanh nhat
while (NutDau == Push);
_time = fast; //30 la muc nhanh nhat co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
Checkback = 1;
}
else if (NutGiua == Push) { //Neu nhan NutGiua se la muc trung binh
while (NutGiua == Push);
_time = mid; //50 la muc trung binh co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
Checkback = 0;
}
else if (NutKeCuoi == Push) { //Neu nhan NutGiua se la muc cham nhat
while (NutKeCuoi == Push);
_time = low; //70 la muc cham nhat co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
Checkback = 2;
}
else if (NutCuoi == Push) { //Luc nay neu khong chon thoi gian thi NutCuoi la nut BACK or ACCEPT thoi gian da chon
while (NutCuoi == Push);
if (Checkback != 5) { //Check neu DUNG se ACCEPT thoi gian da chon
if (_time == fast) {ADDWORD(40, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
else if (_time == mid) {ADDWORD(41, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
else if (_time == low) {ADDWORD(42, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
if (id == 1) {Nut_Nut_Dau(_time);}
else if (id == 0) {Nut_Nut_Giua(_time);}
else if (id == 2) {Nut_Nut_Ke_Cuoi(_time);}
else if (id == 3) {Nut_Nut_Cuoi(_time);}
else if (id == 4) {} // Set lai thoi gian cho cai truong hop ADDWORD
Check_Nhan_Giu_Nut--;
}
else { // Neu SAI se quay ve trang thai truoc do
if (id == 1) {
ADDWORD(37, 40); // Mat SAD voi time = 40
Nut_Nut_Dau(default_time); // Trang thai truoc do
}
else if (id == 0) {
ADDWORD(27, 40); // Mat SAD voi time = 40
Nut_Nut_Giua(default_time); // Trang thai truoc do
}
else if (id == 2) {
ADDWORD(37, 40); // Mat SAD voi time = 40
Nut_Nut_Ke_Cuoi(default_time); // Trang thai truoc do
}
else if (id == 3) {
ADDWORD(37, 40); // Mat SAD voi time = 40
Nut_Nut_Cuoi(default_time); // Trang thai truoc do
}
Check_Nhan_Giu_Nut--;
}
}
}
while (Check_Nhan_Giu_Nut < 5) {
id = 2;
Nut_Nut_Ke_Cuoi(default_time);
if ((NutDau == Push) || (NutGiua == Push) || (NutKeCuoi == Push) || (NutCuoi == Push))
break;
}
Check_Nhan_Giu_Nut = 0;
}
//LUU Y KHI SET TIME VOI CHU DUOC NHAP VAO SE !!!! KKHONGGGG !!!!! CO NUT BACKKKKK nhung van Set lai thoi gian cho chuc nang ADDWORD duoc
else if (NutCuoi == Push) { //Neu Nhan Nut Cuoi khong giu qua 3s se nhay vao mode Nut Cuoi
int _Select = 0; // Bien nay dung de di chuyen den vi tri cac chu cai khi xai mode ADD WORD
Buffer = 1;
while (NutCuoi == Push) { //Neu Nhan va Giu Nut Cuoi qua 3s se nhay vao Mode ADD WORD
Check_Nhan_Giu_Nut++;
delay(100);
if (Check_Nhan_Giu_Nut == 5)
break;
}
if (Check_Nhan_Giu_Nut == 5) {
while (NutCuoi == Push)
Behon30(); // Neu da vao duoc Mode ADD WORD se hien thi thong bao nhap vao ky tu <30
Check_Nhan_Giu_Nut++;
}
while (Check_Nhan_Giu_Nut > 5) {
SELECT(_Select); //Hien thi cac chu cai
if (NutDau == Push) //DOWN
{
delay(150);
_Select--;
if(_Select < 0 )
_Select = 1;
}
else if (NutGiua == Push) { //UP
delay(150);
_Select++;
if(_Select > 36 )
_Select = 36;
}
else if (NutCuoi == Push) { //Sau khi di chuyen den chu can chon , nut nay se co chuc nang ACCEPT
while (NutCuoi == Push) {
drawScreen(Alert_Add_Word_OK); //Thong bao thanh cong (chop nhanh 1 cai 4 goc)
}
if(_Select == 0) //Neu dang trong chuc nang ADD WORD ma k muon chon chu nua thi NutCuoi la BACK
{
Check_Nhan_Giu_Nut -= 2;
ADDWORD(37, 40); // Mat SAD voi time = 40
}
if (Buffer <= 30 && Buffer > 0) { // Neu nhap vao lon hon 30 ky tu se thong bao va be hon 0 se thong bao
Array[Buffer] = _Select;
Buffer++;
}else Behon30(); // Neu nhap vao lon hon 30 ky tu se thong bao
}
else if (NutKeCuoi == Push) { // Khi thuc hien xong ADD WORD , nut nay se co chuc nang Set Time
while (NutKeCuoi == Push);
while (Check_Nhan_Giu_Nut > 5 && Buffer > 1) { //_Seclect = 0 tranh tinh trang chua chon chu ma da SetTime
drawScreen(TimeMenu); //Hien thi ba muc Time mac dinh cho nguoi dung chon
if (NutDau == Push) { //Neu nhan NutDau se la muc nhanh nhat
while (NutDau == Push);
_time = fast; //30 la muc nhanh nhat co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
}
else if (NutGiua == Push) { //Neu nhan NutGiua se la muc trung binh
while (NutGiua == Push);
_time = mid; //50 la muc trung binh co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
}
else if (NutKeCuoi == Push) { //Neu nhan NutCuoi se la muc cham nhat
while (NutKeCuoi == Push);
_time = low; //70 la muc cham nhat co the thay doi
Speed_Display(_time); //DEMO cho nguoi dung xem thu voi chu TRY
}
else if (NutCuoi == Push) { // Xong viec ADD WORD va Set Time , thi NutCuoi co chuc nang ACCEPT
while (NutCuoi == Push);
if (_time == fast) {ADDWORD(40, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
else if (_time == mid) {ADDWORD(41, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
else if (_time == low) {ADDWORD(42, 40);} // Hien cho nguoi dung biet da set loai thoi gian nao
else _time = default_time;
id = 4;
Check_Nhan_Giu_Nut--;
}
}
if(Buffer < 2 && _Select > 0)
ADDWORD(38, 40); // Hien mui ten huong dan bam SET WORD
}
}
while (Check_Nhan_Giu_Nut < 5) {
id = 3;
Nut_Nut_Cuoi(default_time);
if ((NutDau == Push) || (NutGiua == Push) || (NutKeCuoi == Push) || (NutCuoi == Push))
break;
}
Check_Nhan_Giu_Nut = 0;
}
for (int i = 1; i < Buffer; i++)
ADDWORD(Array[i], _time); // HIEN THI CHU DA NHAP
}
File header Function.h
#define ROW_1 7 //2
#define ROW_2 10 //3
#define ROW_3 5 //4
#define ROW_4 11 //5
#define ROW_5 A2 //6
#define ROW_6 4 //7
#define ROW_7 A0 //8
#define ROW_8 A5 //9
#define COL_1 A1 //10
#define COL_2 9 //11
#define COL_3 8 //12
#define COL_4 A4 //13
#define COL_5 6 //A0
#define COL_6 A3 //A1
#define COL_7 13 //A2
#define COL_8 12 //A3
#define NutDau digitalRead(1)
#define NutGiua digitalRead(0)
#define NutKeCuoi digitalRead(2)
#define NutCuoi digitalRead(3)
#define Push 0
#define default_time 20
#define fast 5
#define mid 25
#define low 40
float timeCount = 0;
int Check_Nhan_Giu_Nut = 0; // Bien kiem tra co an giu nut qua 3s hay k
int Checkback; // Bien Check de co the BACK khi dang trong mode SET TIME cho cac chu mac dinh
int Array[30]; // Mot cai mang chua 30 ki tu
int Buffer = 1; // Ta su dung phan tu cua mang tu phan tu thu 2 ( tuc la = 1)
int _time = 0; // Bien set time
int id; // Bien Id tuong ung voi tung chan cua tung nut : Dau(1) Giua(0) Ke(2) Cuoi(3)
const byte rows[] = {
ROW_1, ROW_2, ROW_3, ROW_4, ROW_5, ROW_6, ROW_7, ROW_8
};
// The display buffer
// It's prefilled with a smiling face (1 = ON, 0 = OFF)
byte TEST[] = {B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111};
byte TIM1[] = {B00101000,B01010100,B01000100,B00101000,B00010000,B00000000,B00000000,B00000000};
byte TIM2[] = {B00000000,B01010000,B10101000,B10001000,B01010000,B00100000,B00000000,B00000000};
byte TIM3[] = {B00000000,B00000000,B01010000,B10101000,B10001000,B01010000,B00100000,B00000000};
byte TIM4[] = {B00000000,B00000000,B00000000,B00101000,B01010100,B01000100,B00101000,B00010000};
byte TIM5[] = {B00000000,B00000000,B00000000,B00010100,B00101010,B00100010,B00010100,B00001000};
byte TIM6[] = {B00000000,B00000000,B00001010,B00010101,B00010001,B00001010,B00000100,B00000000};
byte TIM7[] = {B00000000,B00001010,B00010101,B00010001,B00001010,B00000100,B00000000,B00000000};
byte TIM8[] = {B00010100,B00101010,B00100010,B00010100,B00001000,B00000000,B00000000,B00000000};
byte SAD[] = {B00000000,B01100110,B01100110,B00000000,B00011000,B00100100,B01000010,B00000000};
byte Chamthan[] = {B00000000,B01010100,B01010100,B01010100,B01010100,B00000000,B01010100,B00000000};
byte Bacham[] = {B00000000,B00000010,B00000010,B00000010,B00000010,B00000000,B01111010,B00000000};
byte Alert_Add_Word_OK[] = {B10000001,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B10000001};
byte GuidePushDown[] = {B00000000,B00000000,B00100000,B01000000,B11111111,B01000000,B00100000,B00000000};
byte GuidePushSetWord[]={B00000000,B00000000,B00000000,B00000000,B00010000,B10100000,B11000000,B11100000};
byte Clear[] = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte TimeMenu[] = {B11100000,B11111100,B11111111,B00000000,B00010000,B10100000,B11000000,B11100000};
byte _FAST[] = {B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte _MID[] = {B00000000,B11111100,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000};
byte _LOW[] = {B00000000,B00000000,B11111111,B00000000,B00000000,B00000000,B00000000,B00000000};
byte Behon3[] = {B00010110,B00100001,B01000001,B10000110,B01000001,B00100001,B00010110,B00000000};
byte Behon0[] = {B00010010,B00100101,B01000101,B10000101,B01000101,B00100101,B00010010,B00000000};
byte ModeX1[] = {B10000001,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B10000001};
byte ModeX2[] = {B10000001,B01000010,B00000000,B00000000,B00000000,B00000000,B01000010,B10000001};
byte ModeX3[] = {B10000001,B01000010,B00100100,B00000000,B00000000,B00100100,B01000010,B10000001};
byte ModeX4[] = {B10000001,B01000010,B00100100,B00011000,B00011000,B00100100,B01000010,B10000001};
byte A[] = {B00011000,B00111100,B01100110,B01100110,B01111110,B01111110,B01100110,B01100110};
byte B[] = {B01111100,B01100110,B01100110,B01111100,B01111110,B01100110,B01100110,B01111100};
byte C[] = {B00111110,B01111110,B01100000,B01100000,B01100000,B01100000,B01111110,B00111110};
byte D[] = {B01111000,B01111100,B01100110,B01100110,B01100110,B01100110,B01111100,B01111000};
byte E[] = {B01111110,B01111110,B01100000,B01111110,B01111110,B01100000,B01111110,B01111110};
byte F[] = {B01111110,B01111110,B01100000,B01111100,B01111100,B01100000,B01100000,B01100000};
byte G[] = {B00111000,B01111100,B01100100,B01100000,B01101110,B01100100,B01111100,B00111000};
byte H[] = {B01100110,B01100110,B01100110,B01111110,B01111110,B01100110,B01100110,B01100110};
byte I[] = {B01111110,B01111110,B00011000,B00011000,B00011000,B00011000,B01111110,B01111110};
byte J[] = {B01111110,B01111110,B00011000,B00011000,B00011000,B00011000,B01111000,B01110000};
byte K[] = {B01100110,B01101100,B01111000,B01110000,B01110000,B01111000,B01101100,B01100110};
byte L[] = {B01100000,B01100000,B01100000,B01100000,B01100000,B01100000,B01111110,B01111110};
byte M[] = {B01000010,B01100110,B01111110,B01011010,B01000010,B01000010,B01000010,B01000010};
byte N[] = {B01000110,B01100110,B01100110,B01110110,B01111110,B01101110,B01100110,B01100110};
byte O[] = {B00111100,B01111110,B01100110,B01100110,B01100110,B01100110,B01111110,B00111100};
byte P[] = {B01111000,B01111100,B01100110,B01100110,B01111100,B01111000,B01100000,B01100000};
byte Q[] = {B00111100,B01000010,B01000010,B01000010,B01000010,B01001010,B00111100,B00000010};
byte R[] = {B01111100,B01100110,B01100110,B01101100,B01111000,B01111000,B01101100,B01100110};
byte S[] = {B00111100,B01111110,B01100000,B01111100,B00111110,B00000110,B01111110,B00111100};//{B00111000,B01111100,B01100000,B00110000,B00011000,B00001100,B00111100,B01111000};
byte T[] = {B01111110,B01111110,B00011000,B00011000,B00011000,B00011000,B00011000,B00011000};
byte U[] = {B01100110,B01100110,B01100110,B01100110,B01100110,B01100110,B01111110,B00111100};
byte V[] = {B01100110,B01100110,B01100110,B01100110,B01100110,B01100110,B00111100,B00011000};
byte W[] = {B01000010,B01000010,B01000010,B01000010,B01000010,B01011010,B01011010,B00100100};
byte X[] = {B01100110,B01100110,B01100110,B00111100,B00011000,B00111100,B01100110,B01100110};
byte Y[] = {B01100110,B01100110,B01100110,B01111110,B00111100,B00011000,B00011000,B00011000};
byte Z[] = {B01111110,B01111110,B00000110,B00001100,B00011000,B00110000,B01111110,B01111110};
byte Zero[] = {B00111100,B01111110,B01100110,B01100110,B01100110,B01100110,B01111110,B00111100}; // Giong chu O
byte One[] = {B00011000,B00111000,B01111000,B00011000,B00011000,B00011000,B01111110,B01111110};
byte Two[] = {B00111100,B01111110,B01000110,B00001100,B00011000,B00110000,B01111110,B01111110};
byte Three[] = {B01111100,B01111110,B00000110,B00111110,B00111110,B00000110,B01111110,B01111100};
byte Four[] = {B00001100,B00011100,B00111100,B01101100,B01111110,B01111110,B00001100,B00001100};
byte Five[] = {B01111110,B01111110,B01100000,B01111100,B00111110,B00000110,B01111110,B01111100};
byte Six[] = {B00001100,B00011000,B00110000,B01111100,B01111110,B01100110,B01100110,B00111100};
byte Seven[] = {B01111110,B01111110,B00000110,B00000110,B00001100,B00011000,B00110000,B01100000};
byte Eight[] = {B00111100,B01100110,B01100110,B00111100,B01111110,B01100110,B01100110,B00111100};
byte Nine[] = {B00111100,B01100110,B01100110,B01111110,B00111110,B00001100,B00011000,B00110000};
void setColumns(byte b) {
digitalWrite(COL_1, (~b >> 0) & 0x01); // Get the 1st bit: 10000000
digitalWrite(COL_2, (~b >> 1) & 0x01); // Get the 2nd bit: 01000000
digitalWrite(COL_3, (~b >> 2) & 0x01); // Get the 3rd bit: 00100000
digitalWrite(COL_4, (~b >> 3) & 0x01); // Get the 4th bit: 00010000
digitalWrite(COL_5, (~b >> 4) & 0x01); // Get the 5th bit: 00001000
digitalWrite(COL_6, (~b >> 5) & 0x01); // Get the 6th bit: 00000100
digitalWrite(COL_7, (~b >> 6) & 0x01); // Get the 7th bit: 00000010
digitalWrite(COL_8, (~b >> 7) & 0x01); // Get the 8th bit: 00000001
// If the polarity of your matrix is the opposite of mine
// remove all the '~' above.
}
void drawScreen(byte buffer2[]){
// Turn on each row in series
for (byte i = 0; i < 8; i++) {
setColumns(buffer2[i]); // Set columns for this specific row
digitalWrite(rows[i], HIGH);
delay(2); // Set this to 50 or 100 if you want to see the multiplexing effect!
digitalWrite(rows[i], LOW);
}
}
void SELECT(int _Select) // Co the them truong hop o cuoi
{
switch (_Select)
{
case 0: {
drawScreen(GuidePushDown);
break;
}
case 1: {
drawScreen(A);
break; }
case 2: {
drawScreen(B);
break; }
case 3: {
drawScreen(C);
break; }
case 4: {
drawScreen(D);
break; }
case 5: {
drawScreen(E);
break; }
case 6: {
drawScreen(F);
break; }
case 7: {
drawScreen(G);
break; }
case 8: {
drawScreen(H);
break; }
case 9: {
drawScreen(I);
break; }
case 10: {
drawScreen(J);
break; }
case 11: {
drawScreen(K);
break; }
case 12: {
drawScreen(L);
break; }
case 13: {
drawScreen(M);
break; }
case 14: {
drawScreen(N);
break; }
case 15:{
drawScreen(O);
break; }
case 16: {
drawScreen(P);
break; }
case 17: {
drawScreen(Q);
break; }
case 18: {
drawScreen(R);
break; }
case 19: {
drawScreen(S);
break; }
case 20: {
drawScreen(T);
break; }
case 21: {
drawScreen(U);
break; }
case 22: {
drawScreen(V);
break; }
case 23: {
drawScreen(W);
break; }
case 24:{
drawScreen(X);
break; }
case 25:{
drawScreen(Y);
break; }
case 26:{
drawScreen(Z);
break; }
case 27:{
drawScreen(Zero); //SAD
break; }
case 28:{
drawScreen(One); //GuidePushSetWord
break; }
case 29:{
drawScreen(Two);
break; }
case 30:{
drawScreen(Three);
break; }
case 31:{
drawScreen(Four);
break; }
case 32:{
drawScreen(Five);
break; }
case 33:{
drawScreen(Six);
break; }
case 34:{
drawScreen(Seven);
break; }
case 35:{
drawScreen(Eight);
break; }
case 36:{
drawScreen(Nine);
break; }
case 37:{
drawScreen(SAD);
break; }
case 38:{
drawScreen(GuidePushSetWord);
break; }
case 39:{
drawScreen(Bacham);
break; }
case 40:{
drawScreen(_FAST);
break; }
case 41:{
drawScreen(_MID);
break; }
case 42:{
drawScreen(_LOW);
break; }
default:break;
}
}
void Speed_Display(int _time) { // Ham DEMO cho nguoi dung xem thu voi chu TRY
timeCount = 0;
while (timeCount < (_time * 3) + 5) // Bao nhieu chu thi * bay nhieu so
{
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
if (timeCount < _time) {
drawScreen(T);
} else if (timeCount < _time * 2) {
drawScreen(R);
} else if (timeCount < _time * 3) {
drawScreen(Y);
}
}
}
void ADDWORD(int _word, int _time) {
timeCount = 0;
while (timeCount < _time) {
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
SELECT(_word);
}
}
void Behon30() {
timeCount = 0;
while (timeCount < 125) {
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0))
break;
timeCount += 1;
if (timeCount < 20) {
drawScreen(Behon3);
} else if (timeCount < 40) {
drawScreen(Behon0);
} else if (timeCount < 60) {
drawScreen(Behon3);
} else if (timeCount < 80) {
drawScreen(Behon0);
} else if (timeCount < 100) {
drawScreen(Behon3);
} else if (timeCount < 120) {
drawScreen(Behon0);
}
}
}
void Mode_Nut_Dau(int _time) {
timeCount = 0;
while (timeCount < (_time * 8) + 5) // Bao nhieu chu thi * bay nhieu so
{
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
if (timeCount < _time) {
drawScreen(TIM1);
} else if (timeCount < _time * 2) {
drawScreen(TIM2);
} else if (timeCount < _time * 3) {
drawScreen(TIM3);
} else if (timeCount < _time * 4) {
drawScreen(TIM4);
} else if (timeCount < _time * 5) {
drawScreen(TIM5);
} else if (timeCount < _time * 6) {
drawScreen(TIM6);
} else if (timeCount < _time * 7) {
drawScreen(TIM7);
} else if (timeCount < _time * 8) {
drawScreen(TIM8);
}
}
}
void Nut_Nut_Dau(int _time) {
while (1) {
Mode_Nut_Dau(_time);
if ((NutGiua == Push) || (NutCuoi == Push) || (NutKeCuoi == Push))
break;
}
}
void Mode_Nut_Giua(int _time) {
timeCount = 0;
while (timeCount < (_time * 4) + 10) //Bao nhieu chu thi * bay nhieu so
{
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
if (timeCount < _time) {
drawScreen(C);
} else if (timeCount < _time * 2) {
drawScreen(E);
} else if (timeCount < (_time * 2)+5) {
drawScreen(Clear);
} else if (timeCount < _time * 3) {
drawScreen(E);
} else if (timeCount < _time * 4) {
drawScreen(C);
}
}
}
void Nut_Nut_Giua(int _time) {
while (1) {
Mode_Nut_Giua(_time);
if ((NutDau == Push) || (NutCuoi == Push) || (NutKeCuoi == Push))
break;
}
}
void Mode_Nut_Ke_Cuoi(int _time) {
timeCount = 0;
while (timeCount < (_time * 3) + 5) //Bao nhieu chu thi * bay nhieu so
{
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
if (timeCount < (_time)) {
drawScreen(U);
} else if (timeCount < (_time * 2)) {
drawScreen(I);
} else if (timeCount < (_time * 3)) {
drawScreen(T);
}
}
}
void Nut_Nut_Ke_Cuoi(int _time) {
while (1) {
Mode_Nut_Ke_Cuoi(_time);
if ((NutDau == Push) || (NutGiua == Push) || (NutCuoi == Push) || (NutKeCuoi == Push))
break;
}
}
void Mode_Nut_Cuoi(int _time) {
timeCount = 0;
while (timeCount < (_time * 11) + 15) // Bao nhieu chu thi * bay nhieu so
{
if ((NutGiua == 0) || (NutDau == 0) || (NutKeCuoi == 0) || (NutCuoi == 0))
break;
timeCount += 1;
if (timeCount < _time) {
drawScreen(C);
} else if (timeCount < _time * 2) {
drawScreen(H);
} else if (timeCount < _time * 3) {
drawScreen(A);
} else if (timeCount < _time * 4) {
drawScreen(O);
} else if (timeCount < _time * 5) {
drawScreen(T);
} else if (timeCount < _time * 6) {
drawScreen(S);
} else if (timeCount < _time * 7) {
drawScreen(V);
} else if (timeCount < _time * 8) {
drawScreen(K);
} else if (timeCount < _time * 9) {
drawScreen(One);
} else if (timeCount < _time * 10) {
drawScreen(Three);
} else if (timeCount < _time * 11) {
drawScreen(Bacham);
}
}
}
void Nut_Nut_Cuoi(int _time) {
while (1) {
Mode_Nut_Cuoi(_time);
if ((NutDau == Push) || (NutGiua == Push) || (NutCuoi == Push) || (NutKeCuoi == Push))
break;
}
}
Trong bài viết có tham khảo các nguồn:
https://mlab.vn/
https://www.youtube.com/channel/UC8h6OGqOuVsxHqA4H8XXOMQ