Code này là quét theo hàng hay cột vậy các bạn?
Nhân đây cho mình hỏi, bạn nào hiểu về nguyên lý quét theo hàng - theo cột trong matrix giải thích dùm mình với. Cảm ơn!!!
Code:
#include <REGX51.H> sbit DATA = P1^0; //chan xung dich tung bit sbit SH_CP = P1^1; //chan du lieu sbit ST_CP = P1^2; //Chan chot du lieu unsigned char code hang[]= { //CHUYEN QUA MUC TICH CUC 1 (1 sang 0 tat) 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //KHOANG TRONG tat het 0x0,0x0,0x3C,0x3C,0x81,0xC3,0xFF,0xC3,0x81,0x3C,0x3C,0x81,0xC3,0xFF,0xFF,0xFF, //DO 0x3,0x1,0xE4,0xE4,0x1,0x3,0xFF,0x0,0x0,0xF3,0xE7,0x0,0x0,0xFF,0xFF,0xFF, //AN }; unsigned int cot[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; unsigned int n,m,k; void delay(unsigned int s) { unsigned int i; for(i=0;i<s;i++); } void convert(unsigned char x) { unsigned char i; for(i=0;i<=7;i++) { DATA=x&0x80; //lay bit du lieu dau tien la bit D7 x=x<<1; SH_CP=0; SH_CP=1; } } //-------------- xóa ma tr?n ------------- void xoa() { convert(0xff); convert(0xff); convert(0xff); convert(0xff); } void main() { while(1) { for(m=0;m<320;m++)//do dai chu { for(k=0;k<4;k++)//toc do chay chu { for(n=m;n<=7+m;n++) { convert(hang[n]); if(n<8)convert(0xff); else convert(hang[n-8]); if(n<16)convert(0xff); else convert(hang[n-16]); if(n<24)convert(0xff); else convert(hang[n-24]); P2=cot[n-m]; ST_CP=1; ST_CP=0; delay(200); xoa(); } } } } }
Comment