Skip to content

Instantly share code, notes, and snippets.

@bkrajendra
Created November 21, 2019 11:20
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 bkrajendra/54c662b7e573185dc4d231f89f93b827 to your computer and use it in GitHub Desktop.
Save bkrajendra/54c662b7e573185dc4d231f89f93b827 to your computer and use it in GitHub Desktop.
NRF Transmitter / Receiver Code
/*
* Arduino Wireless Communication Tutorial
* Example 1 - Receiver Code
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
/*
* Arduino Wireless Communication Tutorial
* Example 1 - Transmitter Code
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World";
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