Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "RF24.h"
- #include "SPI.h"
- #include "nRF24L01.h"
- RF24 radio(6, 7);
- const byte addresses[][6] = {"ADDR1", "ADDR2"};
- void setup() {
- Serial.begin(9600);
- // Serial.setTimeout(1000);
- radio.begin();
- radio.setAutoAck(true);
- radio.setPALevel(RF24_PA_LOW);
- radio.openWritingPipe(addresses[0]);
- radio.openReadingPipe(1, addresses[1]);
- radio.stopListening();
- }
- void sendData(String s) {
- radio.stopListening();
- delay(50);
- Serial.print("Sending payload ("+s+")...");
- if (radio.write(s.c_str(), sizeof(s))) {
- Serial.println("successfull (response received).");
- } else {
- Serial.println("no response.");
- }
- }
- String input;
- void loop() {
- input = Serial.readStringUntil('\n');
- if (input != "") {
- sendData(input);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement