#include<stc15.h>
#include<intrins.h>
#include<gpio.h>
#define uchar unsigned char
#define uint unsigned int
#include<595hc.h>
sbit SW17=P3^2;
sbit SW18=P3^3;
uint counter=0;
void Delay10ms()
{
unsigned char i, j;
i = 108;
j = 145;
do
{
while (--j);
} while (--i);
}
void main(void)
{
gpio();
while(1)
{
if(SW17==0)
{
Delay10ms();
if(SW17==0)
{
counter++;
if(counter>10)counter=0;
}
while(SW17==0);
}
if(SW18==0)
{
Delay10ms();
if(SW18==0)
{
if(counter!=0)
{
counter--;
}
}
while(SW18==0);
}
Dis_buf[7]=counter%10;
Dis_buf[6]=counter/10%10;
// Dis_buf[5]=counter/100%10;
// Dis_buf[4]=counter/1000%10;
// Dis_buf[3]=counter/10000%10;
display();
}
}
|