小玩LED點(diǎn)陣之-翻頁(yè)顯示
LED顯示屏(點(diǎn)陣)可以顯示變化的數(shù)字、文字、圖形圖像;不僅可以用于室內(nèi)環(huán)境還可以用于室外環(huán)境,具有投影儀、電視墻、液晶顯示屏無(wú)法比擬的優(yōu)點(diǎn)。
LED之所以受到廣泛重視而得到迅速發(fā)展,是與它本身所具有的優(yōu)點(diǎn)分不開(kāi)的。這些優(yōu)點(diǎn)概括起來(lái)是:亮度高、工作電壓低、功耗小、小型化、壽命長(zhǎng)、耐沖擊和性能穩(wěn)定。LED的發(fā)展前景極為廣闊,目前正朝著更高亮度、更高耐氣候性、更高的發(fā)光密度、更高的發(fā)光均勻性,可*性、全色化方向發(fā)展。?
為什么要說(shuō)小玩?因?yàn)檫@個(gè)只是一個(gè)點(diǎn)陣屏的基礎(chǔ)8x8點(diǎn)陣,小得可憐,因此這樣小的屏只能顯示一些簡(jiǎn)單的圖形和數(shù)字,如圖
點(diǎn)陣的驅(qū)動(dòng)程序也不是很復(fù)雜,但是有一道工序要有耐性。就是圖形和數(shù)字的取摸。
后附上每秒變動(dòng)一個(gè)數(shù)字的源程序,下載地址: http://www.51hei.com/f/88dzp1.rar
#includereg52.h>#define uchar unsigned charuchar code tab[11][8]={{0x18,0x24,0x42,0x42,0x42,0x42,0x24,0x18},/*0*/ //共陰{0x18,0x1C,0x18,0x18,0x18,0x18,0x18,0x3C},/*1*/{0x3C,0x66,0x42,0x60,0x30,0x1C,0x86,0x7E},/*2*/{0x3C,0x42,0x40,0x3C,0x40,0x40,0x42,0x3C},/*3*/{0x30,0x38,0x2C,0x26,0x23,0xFF,0x20,0x20},/*4*/{0x7E,0x02,0x3E,0x40,0x40,0x40,0x42,0x3C},/*5*/{0x3C,0x42,0x02,0x3A,0x46,0x42,0x42,0x3C},/*6*/{0x7C,0x42,0x40,0x20,0x10,0x08,0x08,0x08},/*7*/{0x3C,0x42,0x42,0x3C,0x42,0x42,0x42,0x3C},/*8*/{0x3C,0x42,0x42,0x42,0x7C,0x40,0x42,0x3C},/*9*/{0x24,0x7E,0xFF,0xFF,0xFF,0x7E,0x3C,0x18},//心形};uchar count,time,h;bit flag;void delay (uchar t){uchar i=120;while(t--)while(i--); }void init_T() //中斷和定時(shí)器初始化{IE=0x82; //打開(kāi)總中斷,定時(shí)器T1和T0中斷TMOD=0x01; //設(shè)定T1,T0位工作方式1TH0=0x3c;TL0=0xb0; //T0裝初值TR0=1; //開(kāi)始時(shí)鐘開(kāi)始工作}void main(){uchar i;init_T();while(1){for(i=0;i8;i++){ P1=(0x01i);if(!flag) P0=~tab[time%10][i];// else P0=~tab[time/10][i];delay(1);P0=0xff;}}}void time_T0() interrupt 1 //定時(shí)器0,工作方式1,時(shí)鐘中斷{TH0=0x3c;TL0=0xb0; //T0裝初值count++;if(count==20){count=0;time++;/* h++; if(h==10){flag=~flag; //時(shí)鐘計(jì)算,每秒加1h=0;}*/if(time==60){time=0;}}}
評(píng)論