新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 小玩LED點(diǎn)陣之-滾動(dòng)顯示

小玩LED點(diǎn)陣之-滾動(dòng)顯示

作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
細(xì)心的朋友可能會(huì)注意到,上一個(gè)顯示數(shù)字是跳動(dòng)變化的,沒(méi)有動(dòng)感,那不是我們想要的效果,因此,在上一個(gè)的基礎(chǔ)上做些小改動(dòng),變成2秒1幀向上滾動(dòng)。效果如視頻。末尾附上向上滾動(dòng)程序:依然是很簡(jiǎn)單
問(wèn)題來(lái)了,他可以向上滾動(dòng),如果我想他向下滾動(dòng)呢?向左?向右?
思考!思考!
代碼下載:http://www.51hei.com/f/88dz2.rar
#include#define uchar unsigned charuchar code tab[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*空白*/0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x24,0x18,/*0*/  //共陰0x00,0x18,0x1C,0x18,0x18,0x18,0x18,0x18,0x3C,/*1*/0x00,0x3C,0x66,0x42,0x60,0x30,0x1C,0x86,0x7E,/*2*/0x00,0x3C,0x42,0x40,0x3C,0x40,0x40,0x42,0x3C,/*3*/0x00,0x30,0x38,0x2C,0x26,0x23,0xFF,0x20,0x20,/*4*/0x00,0x7E,0x02,0x3E,0x40,0x40,0x40,0x42,0x3C,/*5*/0x00,0x3C,0x42,0x02,0x3A,0x46,0x42,0x42,0x3C,/*6*/0x00,0x7C,0x42,0x40,0x20,0x10,0x08,0x08,0x08,/*7*/0x00,0x3C,0x42,0x42,0x3C,0x42,0x42,0x42,0x3C,/*8*/0x00,0x3C,0x42,0x42,0x42,0x7C,0x40,0x42,0x3C,/*9*/0x00,0x24,0x7E,0xFF,0xFF,0xFF,0x7E,0x3C,0x18,//心形};uchar count;void delay (uchar t){uchar i=100;while(t--)while(i--); }void init_T()   //中斷和定時(shí)器初始化{IE=0x82;  //打開(kāi)總中斷,定時(shí)器T1和T0中斷TMOD=0x01;  //設(shè)定T1,T0位工作方式1TH0=0x9e;TL0=0x58;  //T0裝初值TR0=1;   //開(kāi)始時(shí)鐘開(kāi)始工作}void main(){uchar i,j;init_T();while(1){  for(j=0;j<99;j++)  //控制顯示的字符數(shù),一定要為8的整數(shù)倍{for(count=0;count<5;) //此處控制每個(gè)字的滾動(dòng)時(shí)間,5為1秒一幀,10為2秒,一次類推{for(i=0;i<8;i++) //行掃描,此為8*8點(diǎn)陣,掃描8行{      P1=(0x01<interrupt 1    //定時(shí)器0,工作方式1,時(shí)鐘中斷{TH0=0x9e;TL0=0x58;       //T0裝初值count++;}


評(píng)論


技術(shù)專區(qū)

關(guān)閉