搜索
bottom↓
回复: 3

做个记分牌

[复制链接]

出0入0汤圆

发表于 2011-5-12 09:35:43 | 显示全部楼层 |阅读模式
公司有个篮球场,但不幸被当做排球场。让爱打篮球的我很郁闷,郁闷的是几乎每天都有人打排球,我上哪儿去打篮球呢。
五一放假三天做了个记分牌,实现简单加减功能。

(原文件名:201104271187.jpg)


(原文件名:201104271188.jpg)


(原文件名:201104291196.jpg)


(原文件名:201104301199.jpg)


(原文件名:201105041203.jpg)


(原文件名:201105041204.jpg)


(原文件名:201105121226.jpg)


(原文件名:201105121227.jpg)


(原文件名:201105121228.jpg)


(原文件名:201105121229.jpg)


(原文件名:201105121233.jpg)


(原文件名:201105121235.jpg)

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

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

 楼主| 发表于 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管脚映射                 7  6  5  4  3  2  1
                                    D  E  C  G  B  F  A */

/*H管脚映射                 7  6  5  4  3  2  1
                                    D  C  E  G  F  B  A */

//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[shi];
        Wei3 = 0;
        Delay(1);
        Gdisp;

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

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

        P1 = Disp_tableH[shi];
        Wei1 = 0;
        Delay(1);
        Gdisp;

        P1 = Disp_tableL[ge];
        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);
                                }
                               
                        }
                }

        }               
}

出0入0汤圆

 楼主| 发表于 2011-5-12 09:40:33 | 显示全部楼层
程序太乱了

出0入0汤圆

发表于 2015-3-10 17:17:35 | 显示全部楼层
我用5寸数码管做的一个    用89c51做的     就是不知道怎么从单片机的5v转出12V的电压给数码管供电
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-23 10:23

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表