#include <reg51.h>
unsigned char table[]=
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
sbit q= P1^0;
sbit b= P1^1;
sbit s= P1^2;
sbit g= P1^3;
void delay();
void main()
{
while(1)
{
q=0;
P2=table[5];
delay();
P2=0XFF;
q=1;
b=0;
P2=table[8];
delay();
P2=0XFF;
b=1;
s=0;
P2=table[2];
delay();
P2=0XFF;
s=1;
g=0;
P2=table[3];
delay();
P2=0XFF;
g=1;
}
}
void delay(){
unsigned char i=100;
while(i--); //執(zhí)行一個i--是9微秒。 900微秒
}
//共陽 char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
|