Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <nRF24L01.h>
- #include <printf.h>
- #include <RF24.h>
- #include <RF24_config.h>
- #include <Wire.h>
- #include <SPI.h>
- RF24 radio(7, 6); // CE, CSN
- const byte SendAddress[6] = "006";
- const byte ReceiveAddress[6] = "005";
- void setup() {
- Serial.begin(9600);
- radio.begin();
- radio.openWritingPipe(SendAddress);
- radio.openReadingPipe(1, ReceiveAddress);
- radio.setPALevel(RF24_PA_MAX);
- }
- void loop() {
- radioReceive();
- radioSend("test");
- delay(250);
- }
- void radioReceive() {
- radio.startListening();
- if (radio.available()) {
- char text[32] = "";
- radio.read(&text, sizeof(text));
- Serial.println(text);
- }
- }
- void radioSend(String text) {
- const char *cstr = text.c_str();
- radio.stopListening();
- radio.write(&cstr, sizeof(cstr));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement