#pragma SMALL
#include <REG52.H>
#include "absacc.h"
#define uchar unsigned char
unsigned int i=0;
void delay10ms();
void display_led();
uchar test_count,C;
unsigned char num=0 ;/**[4]={0x00,0x00,0x00,0x00};**/
uchar led[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};//led显示码
sbit p22=P2^2;
void init(void)
{
TMOD=0x20;
TH1=0xf3;//波特率2400
TL1=0xf3;//
PCON=0x00;
SCON=0x50;
TR1=1;
}
uchar receive(void)
{
while(RI==0);
// {
RI=0;
return SBUF;
// }
}
void send(uchar d)
{
//发送数据
SBUF=d;
while(TI==0);TI=0;
}
void main(void)
{ unsigned char b;
init();
while(1){
b=receive();
num=b&0x0F;
display_led(); //led显示
}
}
void display_led()
{
P0=led[num];
p22=0;
} |