Skip to content

Instantly share code, notes, and snippets.

@mithi
Last active March 20, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mithi/ecfeb4d0adb313d14852ff2f1590f50e to your computer and use it in GitHub Desktop.
Save mithi/ecfeb4d0adb313d14852ff2f1590f50e to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN);
const byte ADDRESS[6] = "00001";
const char TEXT[] = "Hello world! Watchout!";
void setup(){
while (!Serial);
Serial.begin(9600);
printf_begin();
radio.begin();
//radio.setAutoAck(false);
radio.setDataRate(RF24_2MBPS);
//RF24_1MBPS, RF24_2MBPS
radio.setPALevel(RF24_PA_MIN);
//RF24_PA_LOW, RF24_LOW
radio.setRetries(3, 5);
// delay, count
radio.openWritingPipe(ADDRESS);
radio.stopListening();
radio.printDetails();
}
void loop(){
radio.write(&TEXT, sizeof(TEXT));
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment