zhengdahe 发表于 2011-5-12 09:35:43

做个记分牌

公司有个篮球场,但不幸被当做排球场。让爱打篮球的我很郁闷,郁闷的是几乎每天都有人打排球,我上哪儿去打篮球呢。
五一放假三天做了个记分牌,实现简单加减功能。
http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639254ZPT3N3.jpg
(原文件名:201104271187.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639255WA829B.jpg
(原文件名:201104271188.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639256QKBBI1.jpg
(原文件名:201104291196.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639257A81NHS.jpg
(原文件名:201104301199.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639258O602V7.jpg
(原文件名:201105041203.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639259OPIJ4Q.jpg
(原文件名:201105041204.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639260N5ZFZX.jpg
(原文件名:201105121226.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639261VQVJJZ.jpg
(原文件名:201105121227.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639262WEN7VR.jpg
(原文件名:201105121228.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639263RN4EMW.jpg
(原文件名:201105121229.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639264CS2FQA.jpg
(原文件名:201105121233.jpg)

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_639265BN92R7.jpg
(原文件名:201105121235.jpg)

蓄电池时朋友的,全新一次没用,但放了好久。充不进去电,拿去激活,激不活,又灌了啥液体,店老板说是兑的什么专用蓄电池的。拿回去还是充不进去电,我就反充,发现反充后有充电电流,然后就反充一会,正充一会。中间充到电压7V,接着反充,反充的时候看了个电影,两个小时过去了,发现电池还在反充,吓坏了,但是电池好像被激活了,再充电就好了,一直都有充电电流,充了一晚上充到了12V,能亮一天还有电

zhengdahe 发表于 2011-5-12 09:39:49

#include<reg52.h>
sbit Wei1 = P1^0;
sbit Wei2 = P3^7;
sbit Wei3 = P3^4;
sbit Wei4 = P3^5;

sbit Ajia = P3^1;
sbit Ajian = P3^0;
sbit Bjia = P3^2;
sbit Bjian = P3^3;

#define Gdisp   Wei1 = 1; Wei2 = 1; Wei3 = 1; Wei4 = 1;

/* 数码牌P0口段选
数码管是用热转印做的,先画好一个,另一个是用的镜像,所以码表不一样

        H(高位)   L(低位)
          a                              a
       ---                     ---
   b|   |f              f |   |b
        | g |                        | g |
       ---                     ---
   c|   |e              e |   |c
        |   |                        |   |
       ---                     ---
          d                        d

/*L管脚映射               7654321
                                  DECGBFA */

/*H管脚映射               7654321
                                  DCEGFBA */

//unsigned char Disp_table[]={0x11,0xd7,0x25,0x45,0xc3,0x49,0x09,0xd5,0x01,0x41};          //共阴极
//unsigned char Disp_tableL[]={0xee,0x28,0xda,0xba,0x3c,0xb6,0xf6,0x2a,0xfe,0xbe};          //共阳极
//unsigned char Disp_tableH[]={0xee,0x44,0xb6,0xd6,0x5c,0xda,0xfa,0x46,0xfe,0xde};          //共阳极
unsigned char Disp_tableL[]={0xef,0x29,0xdb,0xbb,0x3d,0xb7,0xf7,0x2b,0xff,0xbf};          //共阳极
unsigned char Disp_tableH[]={0xef,0x45,0xb7,0xd7,0x5d,0xdb,0xfb,0x47,0xff,0xdf};          //共阳极          因段码表不显示小数点,P1.0为位选,电路使用ULN2003驱动段码,所以码表都要加1,使P1.0输出高
unsigned char Ascore=0,Bscore=0;
//unsigned char Aflag=0 ,Bflag=0;
void Delay(unsigned int count)
{
        unsigned int i,iTemp;
        for(iTemp=0;iTemp<count;iTemp++)
        for(i=0;i<110;i++);
}
void Ascore_Display(unsigned int i)
{
        unsigned char ge,shi;
        ge = i%10;
        shi = i/10;

        P1 = Disp_tableH;
        Wei3 = 0;
        Delay(1);
        Gdisp;

        P1 = Disp_tableL;
        Wei4 = 0;
        Delay(1);
        Gdisp;
}

void Bscore_Display(unsigned int i)
{
        unsigned char ge,shi;
        ge = i%10;
        shi = i/10;

        P1 = Disp_tableH;
        Wei1 = 0;
        Delay(1);
        Gdisp;

        P1 = Disp_tableL;
        Wei2 = 0;
        Delay(1);
        Gdisp;

}

void init_tc0()
{
        TMOD=0X01;
        TH0=(65535-10000)/256;
        TL0=(65535-10000)%256;
        EA=1;
        ET0=1;
        TR0=1;
}
void tc0_srv() interrupt 1
{
        TH0=(65535-10000)/256;
        TL0=(65535-10000)%256;
        Ascore_Display(Ascore);
        Bscore_Display(Bscore);                          // 分值没有变化
}

main()
{
        unsigned int Atemp,Count_Temp,Jia_Temp,Jia_Temp1=0;
        Jia_Temp = 600;
        Ascore = 0;
        Bscore = 0;
        init_tc0();
        while(1)
        {
                                                               
               if(Ajia == 0)                                                                                    //       Ascore加分
                {
                        Delay(50);
                       if(Ajia == 0)
                        {
                                Ascore++;
                                if(Ascore == 100) Ascore = 0;
                                EA = 0;                                                                                //CLOSE INERRUPT
                                for(Atemp=0;Atemp<3;Atemp++)
                                {
                                        for(Count_Temp=0;Count_Temp<20;Count_Temp++)
                                        {
                                                Ascore_Display(Ascore);
                                                Bscore_Display(Bscore);
                                                Delay(8);                                                  // A B 都显示
                                        }
       
                                        for(Count_Temp=0;Count_Temp<20;Count_Temp++)
                                        {
                                                Bscore_Display(Bscore);                          // 只显示B,实现闪烁A的效果
                                                Delay(8);
                                        }
                               
                                }
                                EA = 1;


                                if(Ajia == 0)                                                          //实现连续加功能
                                {
                                        Delay(10);
                                        while(Ajia == 0)
                                        {
                                                if(Jia_Temp1!=2)
                                                {
                                                        Delay(300);
                                                        Ascore++;
                                                        Jia_Temp1++;
                                                }
                                                if(Jia_Temp1==2)
                                                {
                                                        Delay(150);
                                                       Ascore++;
                                                }                                                                                  
                                        }       
                                Jia_Temp1 = 0;
                               
                                }                            


                        }
                }

               if(Ajian == 0)                                //                Ascore减分
                {
                        Delay(50);
                       if(Ajian == 0)
                        {
                               
                                if(Ascore!=0)
                                {
                                        Ascore--;
                                        while(Ajian==0);
                                }
                               
                        }
                }

               if(Bjia == 0)                                        //                Bscore加分
                {
                        Delay(50);
                       if(Bjia == 0)
                        {
                                Bscore++;
                                if(Bscore == 100) Bscore = 0;

                                EA = 0;                                        //CLOSE INERRUPT
                                for(Atemp=0;Atemp<3;Atemp++)
                                {
                                        for(Count_Temp=0;Count_Temp<20;Count_Temp++)
                                        {
                                                Ascore_Display(Ascore);
                                                Bscore_Display(Bscore);
                                                Delay(8);                                          // A B 都显示
                                        }
       
                                        for(Count_Temp=0;Count_Temp<20;Count_Temp++)
                                        {
                                                Ascore_Display(Ascore);                          // 只显示B,实现闪烁A的效果
                                                Delay(8);
                                        }
                               
                                }
                                EA = 1;

                                if(Bjia == 0)                                                          //实现连续加功能
                                {
                                        Delay(10);
                                        while(Bjia == 0)
                                        {
                                                if(Jia_Temp1!=2)
                                                {
                                                        Delay(300);
                                                        Bscore++;
                                                        Jia_Temp1++;
                                                }
                                                if(Jia_Temp1==2)
                                                {
                                                        Delay(150);
                                                       Bscore++;
                                                }                                                                                  
                                        }
                                Jia_Temp1 = 0;
                               
                                }                            

                        }
                }

               if(Bjian == 0)                                        //               Bscore减分
                {
                        Delay(50);
                       if(Bjian == 0)
                        {
                               
                                if(Bscore != 0)
                                {
                                        Bscore--;
                                        while(Bjian==0);
                                }
                               
                        }
                }

        }               
}

zhengdahe 发表于 2011-5-12 09:40:33

程序太乱了

.Alan. 发表于 2015-3-10 17:17:35

我用5寸数码管做的一个    用89c51做的   就是不知道怎么从单片机的5v转出12V的电压给数码管供电
页: [1]
查看完整版本: 做个记分牌