EasyManua.ls Logo

Emakefun RF-NANO - Page 27

Emakefun RF-NANO
34 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Copy right © 2018 Shenzhen Emakefun Technology co., Ltd.
27
#include <SPI.h>
#include "Mirf.h"
#include "nRF24L01.h"
#include "MirfHardwareSpiDriver.h"
Nrf24l Mirf = Nrf24l(10, 9);
int value;
void setup()
{
Serial.begin(9600);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
//Set your own address (sender address) using 5 characters
Mirf.setRADDR((byte *)"ABCDE");
Mirf.payload = sizeof(value);
Mirf.channel = 20; //Set the channel used
Mirf.config();
}
void loop()
{
Mirf.setTADDR((byte *)"FGHIJ"); //Set the receiver address
value = 200; //0-255 random number
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
delay(1000);
}