單片機(jī)驅(qū)動16*16點(diǎn)陣LED漢字顯示c51程序
//=========================================
//******* 單片機(jī)驅(qū)動16*16點(diǎn)陣LED漢字顯示c51程序 *******
//******* 作者:http://www.51hei.com *******
//=========================================
//晶振12MHz
//P1.0~P1.3接74154行掃描
//P3.0、P3.1接74164串轉(zhuǎn)并
#include reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar int_t;
uchar i;
uchar j;
uchar count=2; //2個(gè)字
uint k=0;
void t0_int() interrupt 1
{
TL0=0x18;
TH0=0x1C;
int_t++;
if(int_t==2) //移動速度2ms
{
int_t=0;
k=k+2;
if(k==count*32)
k=0;
}
}
void delay(uint dt)//2字節(jié)
{
uchar bt;//1字節(jié)
for (;dt;dt--)
{
for (bt=0;bt255;bt++);
}
}
void serial_send(uchar dat)
{
SCON=0x00;
SBUF=~dat;
while(1){ if(TI) {TI=0;break;} }
}
unsigned char code hzdot[64] = {
/*測 CB2E2 */
0x40,0x02,0x27,0xC2,0x24,0x42,0x84,0x52,0x45,0x52,0x55,0x52,0x15,0x52,0x25,0x52,
0x25,0x52,0x25,0x52,0xC5,0x52,0x41,0x02,0x42,0x82,0x42,0x42,0x44,0x4A,0x48,0x04,
/*試 CCAD4 */
0x00,0x20,0x40,0x28,0x20,0x24,0x30,0x24,0x27,0xFE,0x00,0x20,0xE0,0x20,0x27,0xE0,
0x21,0x20,0x21,0x10,0x21,0x10,0x21,0x0A,0x29,0xCA,0x36,0x06,0x20,0x02,0x00,0x00
};
void display()
{
j=k;
for(i=0;i16;i++)
{
P1=i;
serial_send(hzdot[j]);
j++;
serial_send(hzdot[j]);
j++;
if(j==count*32)
j=0;
delay(1);
}
}
void main()
{
SCON=0x00;
TMOD=0x01;
IE|=0x82;
TL0=0x18;
TH0=0x1C;
delay(100);
TR0=1; //啟動T0定時(shí)器
for(;;)
display();
}
評論