#include"c8051f410.h"
#define uchar unsigned char
#define uint unsigned int
sbit rs=P0^7;
sbit rw=P0^6;
sbit en=P0^5;
sbit psb=P0^4;
sbit ret=P0^3;
sbit k1=P0^2;
uchar table[]={"00时58分55秒"};
uchar table1[]={"0123456789"};
uchar key[]={0,0,5,8,5,5};
uchar q,i,j,fl=0;
void fen();
void shi();
void delay(uint x)
{
while(x--);
}
void delayd(uint s)
{
uint d;
while(s--)
for(d=0;d<5000;d++);
}
void writeml(uint com)
{
rs=0;
rw=0;
P2=com;
en=0;
delay(100);
en=1;
delay(100);
}
void writesj(uint dat)
{
rs=1;
rw=0;
P2=dat;
en=0;
delay(100);
en=1;
delay(100);
}
void init()
{
psb=1;
ret=1;
writeml(0x30);
delay(20);
writeml(0x30);
delay(20);
writeml(0x0c);
delay(200);
writeml(0x06);
delay(20);
writeml(0x01);
delay(20);
}
void shijian()
{
q=0;
for(j=0x88;j<0x8e;j++)
{
writeml(j);
for(i=0;i<2;i++,q++)
{
writesj(table[q]);
}
}
}
void miao()
{ shijian();
key[5]++;
if(key[5]<10)
{
writeml(0x8c);
writesj(table1[key[4]]);
writesj(table1[key[5]]);
delayd(4);
}
else
{
key[4]++;
if(key[4]<=5)
{
key[5]=0;
writeml(0x8c);
writesj(table1[key[4]]);
writesj(table1[key[5]]);
}
else if(key[4]==6)
{
key[4]=0;
key[5]=0;
writeml(0x8c);
writesj(table1[key[4]]);
writesj(table1[key[5]]);
}
}
}
void fen()
{
key[3]++;
if(key[3]<10)
{
writeml(0x8a);
writesj(table[key[2]]);
writesj(table[key[3]]);
}
else
{
key[2]++;
if(key[2]<=5)
{
key[3]=0;
writeml(0x8a);
writesj(table[key[2]]);
writesj(table[key[3]]);
}
else if(key[2]>5)
{
key[2]=0;
key[3]=0;
writeml(0x8a);
writesj(table[key[2]]);
writesj(table[key[3]]);
}
}
}
main()
{
PCA0MD&=~0X40;
XBR1=0X40;
P0MDOUT=0X00;
P1MDOUT=0XFC;
P2MDOUT=0X00;
init();
while(1)
{
//shijian();
miao();
//fen();
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>