#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define LED_seg P0
#define LED_com P2
sbit key1=P3^1;
sbit key2=P3^0;
static int i=0;
static int j=0;
uchar code smgduan[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//??0~F??
void delay(uint i)
{
while(i--);
}
void main()
{
LED_com=0x1c;
while(1)
{
delay(1000);
if(key1==0)
{
delay(1000);
if(key1==0)
{
i++;
if(i==16)
i=0;
LED_seg=smgduan[i];
delay(50000);
}
while(key1==0);
}
delay(1000);
if(key2==0)
{
delay(1000);
if(key2==0)
{
i--;
if(i<0)
i=15;
LED_seg=smgduan[i];
delay(50000);
}
while(key1==0);
}
}
}
|