#include
void Js_Scan(void);
void delay(int x);
sbit key=P2^2;
int code LED_Num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //數碼管掃描陣列,共陰極
//int code LED_Num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //共陽極
int i=0,flag=0;
void main()
{
if(key==0&&flag==0)
i++;
flag=1;
}
if(key==1&&flag==1)
flag=0;
Js_Scan();
void Js_Scan() //數碼管掃描函式
uchar j; //定義j資料型別
for(j=0;j
P1=0x00;P0=LED_Num[i];delay(1); //掃描顯示秒錶小數位,點不顯示,稍作延時
void delay(int x) //延時函式,防止數碼管顯示不穩定
int k;
while(x--)
for(k=0;k
#include
void Js_Scan(void);
void delay(int x);
sbit key=P2^2;
int code LED_Num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //數碼管掃描陣列,共陰極
//int code LED_Num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //共陽極
int i=0,flag=0;
void main()
{
if(key==0&&flag==0)
{
i++;
flag=1;
}
if(key==1&&flag==1)
{
flag=0;
}
Js_Scan();
}
void Js_Scan() //數碼管掃描函式
{
uchar j; //定義j資料型別
for(j=0;j
{
P1=0x00;P0=LED_Num[i];delay(1); //掃描顯示秒錶小數位,點不顯示,稍作延時
}
}
void delay(int x) //延時函式,防止數碼管顯示不穩定
{
int k;
while(x--)
for(k=0;k
}