Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //
  2. // https://www.youtube.com/c/LeventeDaradici/videos
  3. //
  4.  
  5.     #include <SPI.h>
  6.     #include <nRF24L01.h>
  7.     #include <RF24.h>
  8.     RF24 radio(9, 10); // CE, CSN, MOSI=11, MISO=12, SCK=13
  9.     const byte address[6] = "00001";
  10.     char text1[32] = "ON";
  11.     char text2[32] = "OFF";
  12.  
  13.     void setup() {
  14.       radio.begin();
  15.       Serial.begin(9600);
  16.       radio.openWritingPipe(address);
  17.       radio.setPALevel(RF24_PA_MAX,1); //can set: RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX
  18.       radio.setDataRate(RF24_250KBPS); //set as: F24_250KBPS, F24_1MBPS, F24_2MBPS ==>250KBPS = longest range
  19.       radio.setChannel(120); //sets channel from 2.4 to 2.524 GHz in 1 MHz increments 2.483.5 GHz is normal legal limit
  20.       radio.stopListening();
  21.  
  22.     }
  23.     void loop() {
  24.       Serial.print(" PA Level:");
  25.       Serial.println(radio.getPALevel());
  26.       Serial.print(" DATA rate:");
  27.       Serial.println(radio.getDataRate());
  28.      
  29.       radio.write(&text1, sizeof(text1));
  30.       delay(500);
  31.      
  32.       radio.write(&text2, sizeof(text2));
  33.       delay(500);
  34.     }