Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <RF24.h>
- #include <RF24_config.h>
- #include <SPI.h>
- #include "printf.h"
- bool waitForAck = false;
- RF24E radio(9, 53);
- void setup()
- {
- Serial.begin(115200);
- delay(250);
- radio.begin();
- radio.setChannel(0x57);
- radio.setPALevel(RF24_PA_LOW);
- radio.enableAckPayload();
- radio.openReadingPipe(1, pipe01_);
- radio.openWritingPipe(pipe02_);
- radio.enableDynamicPayloads();
- radio.startListening();
- }
- void loop()
- {
- if (radio.available())
- {
- char newMessage[33];
- memset(newMessage, 0, sizeof(byte) * 33);
- while (available())
- {radio.read(newMessage, 32);}
- Serial.println("newMessage: " + String((const char*)newMessage));
- delay(1000);
- radio.stopListening();
- char response[32] = "1234567890qwertyuiopasdfghjklzxc";
- radio.write(response, 32);
- unsigned long ack = 0;
- if (radio.isAckPayloadAvailable())
- {
- radio.read(&ack, sizeof(ack));
- Serial.println("ack: " + String(ack));
- }
- radio.startListening();
- }
- }
- #include <RF24.h>
- #include <RF24_config.h>
- #include <SPI.h>
- #include "printf.h"
- bool waitForAck = false;
- RF24E radio(9, 53);
- void setup()
- {
- Serial.begin(115200);
- delay(250);
- radio.begin();
- radio.setChannel(0x57);
- radio.setPALevel(RF24_PA_LOW);
- radio.enableAckPayload();
- radio.openReadingPipe(2, pipe02_);
- radio.openWritingPipe(pipe01_);
- radio.enableDynamicPayloads();
- radio.stopListening();
- char message[32] = "qwertyuiopasdfghjklzxc1234567890";
- radio.write(message, 32);
- radio.startListening();
- }
- void loop()
- {
- if (radio.available())
- {
- char respMessage[33];
- memset(respMessage, 0, sizeof(byte) * 33);
- while (available())
- {radio.read(respMessage, 32);}
- Serial.println("respMessage: " + String((const char*)respMessage));
- }
- }
Add Comment
Please, Sign In to add comment