找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

新人菜鸟做的篮球积分(非完整版) 希望老鸟指点下~

[复制链接]
admin 发表于 2012-9-2 16:44:26 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
希望老鸟能够帮助我改进~~~我也想从中学习到更多的~~~
谢谢~~~~~
以后还有改进的话~~我会上传的~~
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delay(uint z);
void time_init ();
void time_24 ();
void display ();
void fenshu ();
void contr_team();
void jisuan ();
void contr_t ();

uchar conter = 0 ;
uchar temp = 240 ;
uchar wel = 0 ;
uchar fen ;
uchar miao ;
uchar ms ;
uchar startup= 0 ;
uchar t_startup=0 ;


uchar fenshu1= 0 ;
uchar fenshu2= 0 ;
uchar ge1 = 0 ;
uchar shi1 = 0 ;
uchar bai1 = 0 ;
uchar ge2 = 0 ;
uchar shi2 = 0 ;
uchar bai2 = 0 ;
sbit key = P3^0;
sbit key_t = P3^3;
sbit LED = P1^1;
sbit jia1 = P3^1;
sbit jia2 = P3^2;
sbit A_LED = P1^3;
sbit B_LED = P1^4;

uchar code tab []={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};
//yanshi******************************
void delay(uint z)
{
uint i;
for ( ; z > 0; z--)
{
for ( i = 0;i < 124; i++)
{
;
}
}
}

//time chushihua ****************************
void time_init ()
{
TMOD = 0x11;
EA = 1;
ET0 = 1;
TH0 = ( 65536 - 10000 ) / 256;
TL0 = ( 65536 - 10000 ) % 256;
TR0 = 1;
ET1 = 1;
TH1 = ( 65536 - 2000 ) / 256;
TL1 = ( 65536 - 2000 ) % 256;
TR1 = 1;
}

//T1 zhongduan ********************************
void time_1 () interrupt 3
{
TH1 = ( 65536 - 2000 ) / 256;
TL1 = ( 65536 - 2000 ) % 256;
wel ++ ;
if (wel == 8)
{
wel = 0;
}
display () ;

}

//T0 zhongduan *******************************************
void time_0 () interrupt 1
{
TH0 = ( 655536 - 10000 ) / 256;
TL0 = ( 655536 - 10000 ) % 256;
conter ++ ;
time_24 () ;
}

//dispaly *****************************************
void display ()
{
P2 = wel ;

switch ( wel )
{
case 0: P0 = tab [ fen ]; break;
case 1: P0 = ( tab [ miao] | 0x80 ); break;
case 2: P0 = tab [ ms ]; break;
case 3: P0 = 0x40 ; break;
case 4: P0 = tab [ shi1]; break;
case 5: P0 = tab [ ge1 ]; break;
case 6: P0 = tab [ shi2]; break;
case 7: P0 = tab [ ge2 ]; break;
}
}

//team xuanzhe ***************************************
void contr_team ()
{
uchar contr ;
if ( key_t == 0 )
{
delay (100);
if ( key_t == 0 )
{
contr ++ ;
if ( contr % 2 == 1 )
{
t_startup = 1 ;
temp = 0 ;
}
else
{
t_startup = 0 ;
temp = 0 ;
}
}
}
switch ( t_startup )
{
case 0:A_LED = 1 ; B_LED = 0 ; break;
case 1:A_LED = 0 ; B_LED = 1 ; break;
}
}

// control time **********************************
void contr_t ()
{
uchar start;
if ( key == 0 )
{
delay ( 100 );
if ( key == 0 )
{
start ++ ;
if ( start % 2 == 1)
startup = 0 ;
else
startup = 1 ;
}
}

}
//jishi 24s ******************************************
void time_24 ()
{
fen = temp / 100 ;
miao = (temp % 100) / 10 ;
ms = temp % 10 ;
if ( conter == 10 )
{
conter = 0 ;
if ( temp == 0 )
{
temp = 240 ;
startup = 0 ;
LED = 0 ;
}
if ( startup == 1)
{
LED = 1 ;
temp -- ;
}
}
}
// fenshu ****************************************
void fenshu ()
{
if ( jia1 == 0 )
{
delay (100);
if ( jia1 == 0 && startup == 1 && t_startup == 1 )
{
fenshu1 ++;
temp = 0 ;
}
if ( jia1 == 0 && startup == 1 && t_startup == 0 )
{
fenshu2 ++;
temp = 0 ;
}
}
if ( jia2 == 0 )
{
delay (100);
if ( jia2 == 0 && startup == 1 && t_startup == 1 )
{
fenshu1 = fenshu1 + 2 ;
temp = 0 ;
}
if ( jia2 == 0 && startup == 1 && t_startup == 0 )
{
fenshu2 = fenshu2 + 2 ;
temp = 0 ;
}
}
}
// fenshujisuan************************
void jisuan ()
{
ge1 = fenshu1 % 10 ;
shi1 = (fenshu1 % 100) / 10 ;
bai1 = fenshu1 /100 ;

ge2 = fenshu2 % 10 ;
shi2 = (fenshu2 % 100) / 10 ;
bai2 = fenshu2 /100 ;
}

//main***************************************
void main()
{
time_init ();
while (1)
{
contr_t () ;
contr_team() ;
jisuan () ;
fenshu () ;
}
}


复件_t1.txt (4.34 KB, 下载次数: 0)

mini80E原理图.pdf (76.8 KB, 下载次数: 0)
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 01:06 , Processed in 0.056055 second(s), 12 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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