/********** hero lee编写,考试请勿直接移植,否则一切后果自负 **********/
/* 屏蔽的为清翔单片机开发板,若需使用则将没有屏蔽的注释,注释了的打开,*/
/* 学校发的开发板可直接修改学号数组下载 */
/* 此程序须将开发板上的JOE排针上的跳线帽插左边两个即连接VCC与OE */
/*
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code display_lxy[20][8]={ //此数组为学号流动显示数码管代码
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,// 2
0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,// 20
0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,// 201
0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,// 2013
0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,// 20130
0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,// 201306
0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,// 2013060
0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,//20130600
0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,//01306002
0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,//13060021
0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,//30600210
0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,//06002107
0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,//6002107
0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,//002107
0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,//02107
0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,0x00,//2107
0x06,0x3f,0x07,0x00,0x00,0x00,0x00,0x00,//107
0x3f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,//07
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
}; //修改学号对应的数码管码
//0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0~9
sbit we=P2^7;
sbit du=P2^6;
uchar ci=0,i,temp;
void init() //初始化
{
TMOD=0x01;
EA=1;
ET0=1;
TH0=(65536-46082)/256;
TL0=(65536-46082)%256;
TR0=1;
}
void delay_ms(uint z) //毫秒级延时
{
uint y;
for(;z>0;z--)
for(y=115;y>0;y--);
}
void main()
{
init();
while(1)
{
for (i=0;i<8;i++)
{
P0=0;
du=1;
P0=0;
du=0;
P0=0xff;
we=1;
P0=_crol_(0xfe,i);
we=0;
P0=0;
du=1;
P0=display_lxy[ci][i]; //动态显示
du=0;
delay_ms(1);
}
}
}
void print() interrupt 1
{
static uchar z=0;
z++;
if(z==10)
{
z=0;
if (ci<19)
ci++; //次数更新
else
ci=0;
}
TH0=(65536-46082)/256;
TL0=(65536-46082)%256;
}
*/
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code display_lxy[20][8]={ //此数组为学号流动显示数码管代码
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5b,// 2
0x00,0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,// 20
0x00,0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,// 201
0x00,0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,// 2013
0x00,0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,// 20130
0x00,0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,// 201306
0x00,0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,// 2013060
0x5b,0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,//20130600
0x3f,0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,//01306002
0x06,0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,//13060021
0x4f,0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,//30600210
0x3f,0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,//06002107
0x7d,0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,//6002107
0x3f,0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,//002107
0x3f,0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,//02107
0x5b,0x06,0x3f,0x07,0x00,0x00,0x00,0x00,//2107
0x06,0x3f,0x07,0x00,0x00,0x00,0x00,0x00,//107
0x3f,0x07,0x00,0x00,0x00,0x00,0x00,0x00,//07
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//7
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
}; //修改学号对应的数码管码
//0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0~9
sbit a=P2^2;
sbit b=P2^3;
sbit c=P2^4; //端口定义
uchar ci=0,i,temp;
void init() //初始化
{
TMOD=0x01;
EA=1;
ET0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
}
void delay_ms(uint z) //毫秒级延时
{
uint y;
for(;z>0;z--)
for(y=125;y>0;y--);
}
void display()
{
P0=0; c=0;b=0;a=0; P0=display_lxy[ci][7]; delay_ms(1);
P0=0; c=0;b=0;a=1; P0=display_lxy[ci][6]; delay_ms(1);
P0=0; c=0;b=1;a=0; P0=display_lxy[ci][5]; delay_ms(1);
P0=0; c=0;b=1;a=1; P0=display_lxy[ci][4]; delay_ms(1);
P0=0; c=1;b=0;a=0; P0=display_lxy[ci][3]; delay_ms(1);
P0=0; c=1;b=0;a=1; P0=display_lxy[ci][2]; delay_ms(1);
P0=0; c=1;b=1;a=0; P0=display_lxy[ci][1]; delay_ms(1);
P0=0; c=1;b=1;a=1; P0=display_lxy[ci][0]; delay_ms(1);
}
void main()
{
init();
while(1)
display();
}
void print() interrupt 1
{
static uchar z=0;
z++;
if(z==10)
{
z=0;
if (ci<19)
ci++; //次数更新
else
ci=0;
}
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
}
|