315M单片机无线解码--HS2262
unsigned char i=0x01;
i=i<1+1;
其结果i的值为4,而不是3。
C语言除法运算中,余数的符合要求和被除数的符号一致,比如:2/(-2); 结果为FF(-1), 2%(-2)=0
/********************************************************/
#include
unsigned char counter=0;
unsigned char Receive[3];
sbit RemPin=P0^0;
static bit flag=0;
sbit LED=P2^0;
sbit LED1=P2^5;
void delay( )
{
unsigned char i;
for(i=0;i<50;i++);
}
void delay_nms(unsigned int n)
{
unsigned int i=0,j=0;
for (i=n;i>0;i--)
for (j=0;j<1140;j++);
}
void scan()
{
unsigned char i=0;
unsigned char j=0;
unsigned char Time=10;
unsigned int count=0;
Receive[0]=Receive[1]=Receive[2]=0;
while(--Time)
{
count=0;
while(RemPin)
{
count++;
delay();
if(count>30)
{
break;
}
}
if((count>25)||(count<10))
{
continue;
}
count=0;
while(!RemPin)
{
count++;
delay( );
if(count>660)
{
break;
}
}
if((count>655)||(count<600))
{
continue;
}
count=0;
for(j=0;j<3;j++)
{
for(i=0;i<8;i++)
{
while(RemPin);
count=0;
while(!RemPin)
{
count++;
delay( );
if(count>=85)
{
return;
}
}
if((count>15)&&(count<42))
{
//counter=count;
Receive[j]=Receive[j]<1;
Receive[j]=Receive[j]+0x01;
}
else if((count>45)&&(count<75))
{
Receive[j]=Receive[j]<1;
//counter=count;
}
else
{
//LED1=~LED1;
Receive[0]=Receive[1]=Receive[2]=0;
counter=count;
return;
}
while(RemPin);
}
}
flag=1;
//LED=~LED;
}
}
void main()
{
while(1)
{
scan();
//P1=counter;
if(flag)
{
flag=0;
P1=Receive[2];
P1=~P1;
delay_nms(100);
}
}
}
315M单片机无线解码HS226 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)