MÌNH MỚI COPY ĐƯỢC ĐOẠN CODE NÀY, DÙNG ĐỂ LẬP TRÌNH CHO LED MATRIX. NHƯNG MÌNH KHÔNG HIỂU LẮM, BẠN NÀO CÓ THỂ GIÚP MÌNH ĐƯỢC KHÔNG?
SẮP KT RỒI.
CẢM ƠN MỌI NGƯỜI NHIỀU NHÉ
SẮP KT RỒI.
CẢM ƠN MỌI NGƯỜI NHIỀU NHÉ
Code:
#include <REGX51.H> sbit DATA = P1^0; sbit SH_CP = P1^1; sbit ST_CP = P1^2; unsigned char code hang[100]={ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFC,0xFC,0xFC,0x00,0x00,0xFC,0xFC,0xFC, // T 0xFF,0x00,0x00,0xE7,0xE7,0x00,0x00,0xFF, //H 0xFF,0x03,0x01,0xCC,0xCC,0x01,0x03,0xFF, //a 0xFF,0x00,0x00,0xF3,0xE7,0x00,0x00,0xFF, //N 0xFF,0x00,0x00,0xE7,0xE7,0x00,0x00,0xFF, //H 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//tao khoang trong 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, }; unsigned int cot[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; unsigned int n,m,k; void delay( unsigned int ms) { unsigned int i,j; for(i=0;i<ms;i++); { for(j=0;j<125;j++) {;} } } //--------- Chuye^n no^'i tie^'p sang song song void convert (unsigned int x) { unsigned int n,tg; for(n=0;n<8;n++) { tg=x; tg=tg&0x80; if(tg==0x80) DATA=1; else DATA=0; x=x<<1; SH_CP=0; SH_CP=1; } } void main() { while(1) { for(m=0;m<72;m++)//do dai chu { for(k=0;k<5;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(100); } } } } }
Comment