//发射端程序
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
// * Pins:
// * Hardware SPI:
// * MISO -> 12
// * MOSI -> 11
// * SCK -> 13
// *
// * Configurable:
// * CE -> 8
// * CSN -> 7
int value;
void setup(){
Serial.begin(115200);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"ABCDE"); //设置自己的地址(发送端地址),使用5个字符
Mirf.payload = 10;// sizeof(value);
Mirf.channel = 90; //设置所用信道
Mirf.config();
}
void loop(){
Mirf.setTADDR((byte *)"FGHIJ"); //设置接收端地址
value = random(255); //0-255的随机数
//Mirf.send((byte *)&value); //发送指令,发送随机数value
Mirf.send((byte *)"Hello");
while(Mirf.isSending()) delay(1); //直到发送成功,退出循环
Serial.print("Sent data: ");
Serial.println(value);
delay(1000);
}