您现在的位置:首页 > >

74hc595 74hc154 at89c51 做的点阵 C语言程序

发布时间:

行扫描74hc154 列74hc595移位锁存.51内核单片机
16x80

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define hang P3 //行扫描接在P3口

sbit ds=P1^5; //595数据口
sbit clk=P1^2; //595位移时钟
sbit mr=P1^1; //595复位端
sbit g1=P1^0; //154使能端
sbit g2=P1^4; //595使能端
sbit stcp=P1^3; //595寄存器时钟
uint counter,m,n;
uchar flag;
uchar code hangsz[]={0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff};//行扫描数组


uchar code display[][32]={

/*-- 文字: 莱 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x20,0x08,0x24,0xFF,0xFE,0x09,0x20,0x01,0x08,0x7F,0xFC,0x01,0x00,0x09,0x20,
0x05,0x44,0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,
/*-- 文字: 茵 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x3F,0xF8,0x21,0x08,0x21,0x08,0x2F,0xE8,
0x21,0x08,0x22,0x88,0x22,0x88,0x24,0x48,0x28,0x28,0x20,0x08,0x3F,0xF8,0x20,0x08,

/*-- 文字: 布 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x02,0x00,0x02,0x00,0x02,0x08,0xFF,0xFC,0x04,0x00,0x09,0x00,0x11,0x08,0x3F,0xFC,
0x51,0x08,0x91,0x08,0x11,0x08,0x11,0x08,0x11,0x28,0x11,0x10,0x01,0x00,0x01,0x00,
/*-- 文字: 艺 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x00,0x00,0x3F,0xC0,0x00,0x80,0x01,0x00,
0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x02,0x20,0x02,0x20,0x02,0x1F,0xFE,

/*-- 文字: 店 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x00,0x84,0x3F,0xFE,0x20,0x80,0x20,0x88,0x20,0xFC,0x20,0x80,0x20,0x88,
0x2F,0xFC,0x28,0x08,0x28,0x08,0x28,0x08,0x48,0x08,0x48,0x08,0x8F,0xF8,0x08,0x08,

/*-- 文字:欢 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x80,0x00,0x80,0xFC,0x80,0x04,0xFC,0x45,0x04,0x46,0x48,0x28,0x40,0x28,0x40,
0x10,0x40,0x28,0x40,0x24,0xA0,0x44,0xA0,0x81,0x10,0x01,0x08,0x02,0x0E,0x0C,0x04,

/*-- 文字: 迎 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x41,0x84,0x26,0x7E,0x14,0x44,0x04,0x44,0x04,0x44,0xF4,0x44,0x14,0xC4,
0x15,0x44,0x16,0x54,0x14,0x48,0x10,0x40,0x10,0x40,0x28,0x46,0x47,0xFC,0x00,0x00,

/*-- 文字: 您 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x09,0x00,0x09,0x00,0x13,0xFC,0x12,0x04,0x34,0x48,0x59,0x40,0x91,0x50,0x12,0x4C,
0x14,0x44,0x11,0x40,0x10,0x80,0x02,0x00,0x51,0x84,0x50,0x92,0x90,0x12,0x0F,0xF0,

/*-- 文字: 光 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x01,0x00,0x21,0x08,0x11,0x0C,0x09,0x10,0x09,0x20,0x01,0x04,0xFF,0xFE,0x04,0x40,
0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x40,0x08,0x42,0x10,0x42,0x20,0x3E,0x40,0x00,

/*-- 文字: 临 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x80,0x10,0x80,0x51,0x04,0x51,0xFE,0x52,0x00,0x54,0x80,0x58,0x60,0x50,0x24,
0x57,0xFE,0x54,0x44,0x54,0x44,0x54,0x44,0x54,0x44,0x14,0x44,0x17,0xFC,0x14,0x04};

void delay_ms(uchar tt)
{
for(m=0;m<tt;m++)
for(n=0;n<50;n++);
}

void write_595(uchar shuju) //向595写一个字节的数据
{
uchar i;
for(i=0;i<8;i++)
{
ds=(~shuju)&0x01;
clk=1;
clk=0;
shuju=shuju>>1;
}
}

void main() //主函数
{
uchar i,j,k;
mr=1;
g2=0;
g1=0; //154使能
EA=1; //开总中断
TMOD=0x01; //定时器0工作方式0
ET0=1; //定时器0使能
TH0=(65535-50000)/256; //定时器0设置初值
TL0=(65536-50000)%256;
while(1)
{
for(i=0;i<16;i++) //字从下往上滚动出现
{
k=1;
for(j=i+1;j>0;j--)
{
write_595(display[9][k]);
write_595(display[9][k-1]);
write_595(display[8][k]);
write_595(display[8][k-1]);
write_595(display[7][k]);
write_595(display[7][k-1]);
write_595(display[6][k]);
write_595(display[6][k-1]);
write_595(display[5][k]);
write_595(display[5][k-1]);
k+=2;
hang=hangsz[16-j];
stcp=1;stcp=0;
}
delay_ms(20);
}
TR0=1;flag=1;
while(flag) //停留一秒
{
uchar j;
for(j=0;j<16;j++)
{
write_595(display[9][j*2+1]);
write_595(display[9][j*2]);
write_595(display[8][j*2+1]);
write_595(display[8][j*2]);
write_595(display[7][j*2+1]);
write_595(display[7][j*2]);
write_595(display[6][j*2+1]);
write_595(display[6][j*2]);
write_595(display[5][j*2+1]);
write_595(display[5][j*2]);
hang=hangsz[j];
stcp=1;stcp=0;
}

}
TR0=0;
for(i=16;i>0;i--) //字滚动出显示区
{
k=31;
for(j=i-1;j>0;j--)
{
write_595(display[9][k]);
write_595(display[9][k-1]);
write_595(display[8][k]);
write_595(display[8][k-1]);
write_595(display[7][k]);
write_595(display[7][k-1]);
write_595(display[6][k]);
write_595(display[6][k-1]);
write_595(display[5][k]);
write_595(display[5][k-1]);
k-=2;
hang=hangsz[j];
stcp=1;stcp=0;
}
delay_ms(20);
}
for(i=0;i<16;i++) //下四个字滚动出现在显示区
{
k=1;
for(j=i+1;j>0;j--)
{
write_595(display[4][k]);
write_595(display[4][k-1]);
write_595(display[3][k]);
write_595(display[3][k-1]);
write_595(display[2][k]);
write_595(display[2][k-1]);
write_595(display[1][k]);
write_595(display[1][k-1]);
write_595(display[0][k]);
write_595(display[0][k-1]);
k+=2;
hang=hangsz[16-j];
stcp=1;stcp=0;
}
delay_ms(20);
}


TR0=1;flag=1;
while(flag) //停留一秒
{
uchar j;
for(j=0;j<16;j++)
{
write_595(display[4][j*2+1]);
write_595(display[4][j*2]);
write_595(display[3][j*2+1]);
write_595(display[3][j*2]);
write_595(display[2][j*2+1]);
write_595(display[2][j*2]);
write_595(display[1][j*2+1]);
write_595(display[1][j*2]);
write_595(display[0][j*2+1]);
write_595(display[0][j*2]);
hang=hangsz[j];
stcp=1;stcp=0;
}

}
TR0=0;
for(i=16;i>0;i--) //滚出显示区
{
k=31;
for(j=i-1;j>0;j--)
{
write_595(display[4][k]);
write_595(display[4][k-1]);
write_595(display[3][k]);
write_595(display[3][k-1]);
write_595(display[2][k]);
write_595(display[2][k-1]);
write_595(display[1][k]);
write_595(display[1][k-1]);
write_595(display[0][k]);
write_595(display[0][k-1]);
k-=2;
hang=hangsz[j];
stcp=1;stcp=0;
}
delay_ms(20);
}
}
}


void timer0() interrupt 1 //中断函数
{
counter++;
if(counter==20) //1秒设置
{
counter=0;
flag=0;
}
TH0=(65535-50000)/256;
TL0=(65536-50000)%256;
}


热文推荐
猜你喜欢
友情链接: