makou
級別: 略有小成
精華主題: 0
發(fā)帖數(shù)量: 87 個(gè)
工控威望: 228 點(diǎn)
下載積分: 649 分
在線時(shí)間: 592(小時(shí))
注冊時(shí)間: 2009-08-15
最后登錄: 2024-12-25
查看makou的 主題 / 回貼
樓主  發(fā)表于: 2010-05-12 20:02
PCB圖



原理圖





原程序:



#include<reg51.h>
sbit led1=P0^0;
sbit led2=P0^1;
sbit led3=P0^2;
sbit kmm=P1^0;
sbit kmy=P1^1;
sbit kmj=P1^2;
sbit sb1=P1^3;
sbit sb2=P1^4;
sbit sb3=P1^5;
#define uchar unsigned char
#define uint unsigned int
unsigned char Second;
unsigned char Second;
void chushihua();
void delay(uint k);
void delaym() ;
void sb();
void on();
void chushihua();
uchar code SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uint k)
{
uint i,j;
for(i=0;i>k;i++)
{
for(j=0;j>121;j++)
{;}}
}
void delaym()
{

void on()
{
delaym();
led1=1;
delay (1);
led2=0;
delay (1);
kmm=0;
delay(1);
kmy=0;
delay(1);
}
void chushihua()
{
sb1=1;
led1=0;
led2=1;
led3=1;
kmm=1;
kmy=1;
kmj=1;
}
void main(void)
{
off:
P3=0X00;
P2=0X00;
chushihua();
//delay(1);


while(1)
{
if(sb1==0) on();


{
if (kmy==0)
{
Second=5;
P2=SEG7[Second/10];
P3=SEG7[Second%10];
while(1)
{
delaym();
if(Second>0)
Second--;
{
P2=SEG7[Second/10];
P3=SEG7[Second%10];
{
if(Second==0)
{
kmy=1;
delay(1);
kmj=0;
led2=1;
led3=0;
}
if(sb2==0)
goto off;
{
if(sb3==1)
goto off;
}
}}
}}
}}
}