NRF Transmitter / Receiver Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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