小玩LED點陣之-滾動顯示
問題來了,他可以向上滾動,如果我想他向下滾動呢?向左?向右?
思考!思考!
代碼下載: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() //中斷和定時器初始化{IE=0x82; //打開總中斷,定時器T1和T0中斷TMOD=0x01; //設定T1,T0位工作方式1TH0=0x9e;TL0=0x58; //T0裝初值TR0=1; //開始時鐘開始工作}void main(){uchar i,j;init_T();while(1){ for(j=0;j<99;j++) //控制顯示的字符數(shù),一定要為8的整數(shù)倍{for(count=0;count<5;) //此處控制每個字的滾動時間,5為1秒一幀,10為2秒,一次類推{for(i=0;i<8;i++) //行掃描,此為8*8點陣,掃描8行{ P1=(0x01<interrupt 1 //定時器0,工作方式1,時鐘中斷{TH0=0x9e;TL0=0x58; //T0裝初值count++;}
評論