//51单片机做的红外遥控实验(C语言)
#include
#define u8 unsigned char
#define u16 unsigned int
#define ID 0x00 //本遥控器的ID号
***it ir=P3^3;
code u8 seg[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90}; //0-9的段码
code u8 s[]={1,0x40,0x48,0x04,0x02,0x05,0x54,0x0A,0x1E,0x0E};
u8 buf[4];
bit ir_f=0;
u8 nu;
void delay(u16 x)
{
while(x--);
}
void show(u16 x)
{
u8 i=0,k=0;
u8 s[4];
kk:
s=x%10;
if((x/10)>=1)
{
x=x/10;
i++;
goto kk;
}
k=i+1;
for(i=0;i
{
P0=seg[s];
P2=~(8>>i);
delay(300);
P0=0XFF;
P2=0XFF;
}
}
//51单片机做的红外遥控实验(C语言)
#include
#define u8 unsigned char
#define u16 unsigned int
#define ID 0x00 //本遥控器的ID号
***it ir=P3^3;
code u8 seg[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90}; //0-9的段码
code u8 s[]={1,0x40,0x48,0x04,0x02,0x05,0x54,0x0A,0x1E,0x0E};
u8 buf[4];
bit ir_f=0;
u8 nu;
void delay(u16 x)
{
while(x--);
}
void show(u16 x)
{
u8 i=0,k=0;
u8 s[4];
kk:
s=x%10;
if((x/10)>=1)
{
x=x/10;
i++;
goto kk;
}
k=i+1;
for(i=0;i
{
P0=seg[s];
P2=~(8>>i);
delay(300);
P0=0XFF;
P2=0XFF;
}
}
举报