#include<reg51.h>
#include<stdio.h>
sbit P0_0=P0^0; //10ms信号序列输出
sbit P2_0=P2^0; //信号序列101010
sbit P2_3=P2^3; //信号序列110110
sbit P2_6=P2^6; //信号序列001001
unsigned char num0[6]={0x01,0x00,0x01,0x00,0x01,0x00};
unsigned char num1[6]={0x01,0x01,0x00,0x01,0x01,0x00};
unsigned char num2[6]={0x00,0x00,0x01,0x00,0x00,0x01};
void initial(void)
{
TCON=0x00;
TH0=0xD8;
TL0=0xEF;
TR0=1;
}
void main()
{ int i=0;
while(1)
{
if(P2_0==1)
{
TMOD=0x01;
if(i==6){i=0;}
initial();
do{}while(!TF0);
P0=num0[i++];
}
else if(P2_3==1)
{
TMOD=0x01;
if(i==6){i=0;}
initial();
do{}while(!TF0);
P0=num1[i++];
}
else if(P2_6==1)
{
TMOD=0x01;
if(i==6){i=0;}
initial();
do{}while(!TF0);
P0=num2[i++];
}
}
}