Laboratoriyaning amaliy qismi.
MAX7219 -dagi 8x8 LED matritsasini Arduinoga ulash
Modelni yig‘ish uchun bizga kerak:
Arduino UNO R3 x 1 dona.
LED matritsasi 8 × 8 MAX7219 x 1 dona.
DuPont simlari, 2,54 mm, 20 sm x 1 dona.
Modelning Arduinoga ulanish sxemasi:
DIN moduli pinli Arduino pin8
Arduino pin9 modulining CS pinli
CLK pinli Arduino pin10
VCC moduli pinli 5V quvvat manbai (agar bir nechta matritsali modullar mavjud bo‘lsa, Arduino quvvati etarli bo‘lmaydi va modullar tashqi quvvat manbaidan quvvatlanishi kerak bo‘ladi)
GND pinini modulga ulash
Ushbu model uchun quyidagi dastur yozishimiz mumkin:
unsigned char i;
unsigned char j;
int Max7219_pinCLK = 10;
int Max7219_pinCS = 9;
int Max7219_pinDIN = 8;
unsigned char disp1[33][8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // yurak rasmi
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x40, 0x40, 0x00, 0x00, 0x00,
0x00, 0x80, 0x80, 0x40, 0x40, 0x00, 0x00, 0x00,
0x40, 0x80, 0x80, 0x40, 0x40, 0x00, 0x00, 0x00,
0x60, 0x80, 0x80, 0x40, 0x40, 0x00, 0x00, 0x00,
0x60, 0x90, 0x80, 0x40, 0x40, 0x00, 0x00, 0x00,
0x60, 0x90, 0x88, 0x40, 0x40, 0x00, 0x00, 0x00,
0x60, 0x90, 0x88, 0x44, 0x40, 0x00, 0x00, 0x00,
0x60, 0x90, 0x88, 0x44, 0x44, 0x00, 0x00, 0x00,
0x60, 0x90, 0x88, 0x44, 0x44, 0x08, 0x00, 0x00,
0x60, 0x90, 0x88, 0x44, 0x44, 0x08, 0x10, 0x00,
0x60, 0x90, 0x88, 0x44, 0x44, 0x08, 0x10, 0x20,
0x60, 0x90, 0x88, 0x44, 0x44, 0x08, 0x10, 0x60,
0x60, 0x90, 0x88, 0x44, 0x44, 0x08, 0x90, 0x60,
0x60, 0x90, 0x88, 0x44, 0x44, 0x88, 0x90, 0x60 // yurak rasmi
};
void Write_Max7219_byte(unsigned char DATA) {
unsigned char i;
digitalWrite(Max7219_pinCS, LOW);
for (i = 8; i >= 1; i--) {
digitalWrite(Max7219_pinCLK, LOW);
digitalWrite(Max7219_pinDIN, DATA & 0x80);
DATA = DATA << 1;
digitalWrite(Max7219_pinCLK, HIGH);
}
}
void Write_Max7219(unsigned char address, unsigned char dat) {
digitalWrite(Max7219_pinCS, LOW);
Write_Max7219_byte(address);
Write_Max7219_byte(dat);
digitalWrite(Max7219_pinCS, HIGH);
}
void Init_MAX7219(void) {
Write_Max7219(0x09, 0x00);
Write_Max7219(0x0a, 0x03);
Write_Max7219(0x0b, 0x07);
Write_Max7219(0x0c, 0x01);
Write_Max7219(0x0f, 0x00);
}
void setup() {
pinMode(Max7219_pinCLK, OUTPUT);
pinMode(Max7219_pinCS, OUTPUT);
pinMode(Max7219_pinDIN, OUTPUT);
delay(50);
Init_MAX7219();
}
void loop() {
//yurak rasmini chizami
for (j = 0; j < 17; j++) {
for (i = 1; i < 9; i++)
Write_Max7219(i, disp1[j][i - 1]);
delay(100);
}
// hamma narsani bo‘yash
for (i = 1; i < 9; i++) {
Write_Max7219(i, 0xFF);
delay(100);
}
//все стираем
for (i = 1; i < 9; i++) {
Write_Max7219(i, 0x00);
delay(100);
}
//пауза
delay(800);
}
Arduinoga o‘rnatilgan tugmachani LED bilan shunday ko‘rinishga ega:
Foydalanilgan internet resurslar.
1. https://robotchip.ru/obzor-svetodiodnoy-matritsy-8x8-na-max7219/
2. https://2150692.ru/faq/114-led-matrix-8x8
3. https://www.youtube.com/watch?v=-p2swlsbATw
Laboratoriya ishi uchun topshiriqlar.
1. Laboratoriya ishining nazariy materialini o‘rganish.
2. Bundan tashqari, laboratoriya ishlari uchun ishlatilgan Internet -resurslarni o‘rganing.
3. Arduinosxemalarini o‘zingiz ulang.
4. Arduino IDEda mustaqil ravishda bu ish uchun dastur yozing.
Do'stlaringiz bilan baham: |