3 发送端代码 #include<nRF24L01.h>#include<printf.h>#include<RF24.h>#include<RF24_config.h>#include<SPI.h>#define button1 0#define button2 1#define CE_pin 8#define CSN_pin 9RF24radio(CE_pin,CSN_pin);constbyteaddress[][6]={"00001","00002"};booleansendDatas[2];voidsetup(){pinMo...
NRF24L01_CE = 1; //CE为高,进入接收模式 } 6.读函数 //读取SPI寄存器值 //reg:要读的寄存器 u8 NRF24L01_Read_Reg(u8 reg) { u8 reg_val; NRF24L01_CSN = 0; //使能SPI传输 SPI1_ReadWriteByte(reg); //发送寄存器号 reg_val=SPI1_ReadWriteByte(0XFF);//读取寄存器内容 NRF24L01_CSN = 1; ...
#define button 7 RF24 radio(8, 9); // CE, CSN const byte address[6] = “00001”; boolean buttonState = 0; void setup() { pinMode(button, INPUT); radio.begin(); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MAX); radio.stopListening(); } void loop() { delay(5);...
GPIO_SetBits(GPIOC,GPIO_Pin_5); SPI1_Init(); //初始化SPI1 SPI_Cmd(SPI1,ENABLE); //SPI1使能 NRF24L01_CE = 0; //NRF24L01使能 NRF24L01_CSN = 1; //取消片选 } 下面是接收模式的配置: //NRF24L01的RX模式设置 void NRF24L01_RX_Mode(void) { NRF24L01_CE = 0; NRF24L01_Write_Buf(NRF_WR...
GPIO_PuPd = GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOG, &GPIO_InitStructure);//初始化PG8 GPIO_SetBits(GPIOB,GPIO_Pin_14);//PB14输出1,防止SPI FLASH干扰NRF的通信 SPI1_Init(); //初始化SPI1 NRF24L01_SPI_Init();//针对NRF的特点修改SPI的设置 NRF24L01_CE=0; //使能24L01 NRF24L01_CSN=1; ...
DL-24N 模块共有 8 个 PIN 脚,具体定义如下表: 引脚定义功能说明备注 1VDD电源电压,直流 1.9-3.6V 2CE工作模式选择,TX 或者 RX 模式选择 3CSNCSN=0 有效,SPI 片选使能 4SCLKSPI 时钟 5MOSISPI 数据输入,MOSI 6MISOSPI 数据输出,MISO 7IRQ中断请求端口 ...
(output to CSN, nRF24L01)/ Interrupt signal, from nRF24L01 (input)/ Master In, Slave Out pin (input)/ Serial Clock pin, (output)/ Master Out, Slave In pin (output)extern uchar RX_BUFTX_PLOAD_WIDTH; extern uchar TX_BUFTX_PLOAD_WIDTH; /*/ / Define SPI pins sbit CE= P2A0;sbit ...
sbit CE = P0^0; // Chip Enable pin signal (output) sbit CSN = P0^1; // Slave Select pin, (output to CSN, nRF24L01) sbit IRQ = P0^5; // Interrupt signal, from nRF24L01 (input) sbit MISO = P0^4; // Master In, Slave Out pin (input) ...
SPI_Write_Reg(WRITE_REG + CONFIG,0x0f);// Set PWR_UP bit, enableCE =1;// Set CE pin high to enable RX device}ucharSPI_Read_Reg(uchar reg){ uchar reg_val; CSN =0;// CSN low, initialize SPI communicationSPI_RW(reg);// Select register to read from..reg_val = SPI_RW(0);...
RF24 radio(8, 9); // CE, CSN const byteaddress[6] = “00001”; boolean buttonState = 0; void setup() { pinMode(button, INPUT); radio.begin(); radio.openWritingPipe(address); radio.setPALevel(RF24_PA_MAX); radio.stopListening(); ...