📄 main.c
字号:
#include ".\\nRF24L01\\nRF24L01.h"
#include "def.h"
void Delay(unsigned int s)
{
unsigned int i;
for(i=0; i<s; i++);
for(i=0; i<s; i++);
}
bit old1=1,old2=1,new1=1,new2=1;
unsigned char checkkeys(uchar keynum)
{
switch(keynum)
{
case 1:
new1=UP;
if(old1==1&&new1==0)
{
inerDelay_us(30000);
new1=UP;
if(new1==0){old1=new1;return 1;}
}
old1=new1;
return 0;
break;
case 2:
new2=DOWN;
if(old2==1&&new2==0)
{
inerDelay_us(30000);
new2=DOWN;
if(new2==0){old2=new2;return 1;}
}
old2=new2;
return 0;
break;
}
}
void main(void)
{
unsigned char TxBuf[20]={0}; //
unsigned char RxBuf[20]={0};
init_io() ;
TMOD = 0x11; //设置计数器工作方式为16位装载 ,计数器1波特率发生器2400bps@12MHz
IE = 0xff;
SCON=0x50;
TCLK=1;
RCLK=1;
RCAP2H=0xff;
RCAP2L=0xFD;//115200Bps
TR2=1;
while(1)
{
if(checkkeys(1)){
TxBuf[0]=0;
nRF24L01_TxPacket(TxBuf);
Delay(5000);
}
if(checkkeys(2)){
TxBuf[0]=1;
nRF24L01_TxPacket(TxBuf);
Delay(5000);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -