34af9uc的个人空间 https://bbs.21ic.com/?818997 [收藏] [复制] [RSS]

日志

STC15W408AS@四位数码管

已有 69 次阅读2019-4-9 21:28 |系统分类:兴趣爱好

/********************SU**************************/
/****************QQ774145445*********************/
/***********STC15W408AS@四位数码管***************/
#include<stc15.h>
#define                B0                        0x01
#define                B1                        0x02
#define                B2                        0x04
#define                B3                        0x08
#define                B4                        0x10
#define                B5                        0x20
#define                B6                        0x40
#define                B7                        0x80
sbit                a                        =P1^1;
sbit                b                        =P1^0;
sbit                c                        =P3^7;
sbit                d                        =P3^6;
sbit                e                        =P3^5;
sbit                f                        =P3^4;
sbit                g                        =P3^3;
sbit                h                        =P3^2;
sbit                yi                        =P1^5;
sbit                er                        =P1^6;
sbit                san                        =P1^7;
sbit                si                        =P5^4;
sbit                jiechuqi        =P5^5;
sbit                tantou                =P1^4;
void        chushihua();
void        yanshi(unsigned        char xa);
void        yanshi1();
void        xianshi(unsigned char shuju);
//void        tantoujiance();
unsigned        char        zi[]={
0x03,0x9f,0x25,0x0d,0x99,0x49,
0x41,0x1f,0x01,0x09,0xff};


unsigned char fen,miao,miaoa,haomiao,zhuangtai,dian;
void                main()
{
//unsigned        char        aa;
chushihua();
for(;;)
{
//tantoujiance();
yanshi1();

}


}
void        yanshi1()
{
unsigned char yaa,yab;
yi=0;er=1;san=1;si=1;
yaa=fen/10%10;
yab=zi[yaa];
xianshi(yab);
yanshi(20);


yi=1;er=0;san=1;si=1;
yaa=fen/1%10;
yab=zi[yaa];
xianshi(yab);
yanshi(20);


yi=1;er=1;san=0;si=1;
yaa=miao/10%10;
yab=zi[yaa];
xianshi(yab);
yanshi(20);

//while(1);
yi=1;er=1;san=1;si=0;
yaa=miao/1%10;
yab=zi[yaa];
xianshi(yab);
yanshi(20);

}
void        yanshi(unsigned        char xa)
        {
        unsigned        char xb;
        for(xa;xa>0;xa--)
                {

                for(xb=40;xb>0;xb--);
                }
       
        }
void        xianshi(unsigned char shuju)
{
if(shuju&B7)a=1;else{a=0;}
if(shuju&B6)b=1;else{b=0;}
if(shuju&B5)c=1;else{c=0;}
if(shuju&B4)d=1;else{d=0;}
if(shuju&B3)e=1;else{e=0;}
if(shuju&B2)f=1;else{f=0;}
if(shuju&B1)g=1;else{g=0;}
if(shuju&B0)h=1;else{h=0;}
}

/*void        tantoujiance()
{

tantou=1;
yanshi(1);
if(tantou==1)
        {
        jiechuqi=1;
        }
if(tantou==0)
        {
        jiechuqi=0;
        }
tantou=0;
yanshi(1);

}*/
void        chushihua()
{
        AUXR |= 0x80;                //定时器时钟1T模式
        TMOD &= 0xF0;                //设置定时器模式
        TL0 = 0xAE;                //设置定时初值
        TH0 = 0xFB;                //设置定时初值
        TF0 = 0;                //清除TF0标志
        TR0 = 1;                //定时器0开始计时
    ET0 = 1;        //使能定时器0中断
    EA = 1;
P5M1                &=~B5;
P5M0                |=B5;
fen=15;
miao=66;
}
void mmm() interrupt 1
{
haomiao++;
if(tantou==0)
{jiechuqi=0;}
if(haomiao==5)
        {
        miaoa=1;
        }
if(haomiao==10)
{
haomiao=0;
miaoa=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==15)
{
fen=0;
jiechuqi=0;

}

}
}


}

路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)