Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- RF24 radio(10, 9); // CE, CSN pins
- const byte address[6] = "1Node"; // Unique address
- double errors = 0, itterations = 0;
- void setup() {
- Serial.begin(9600);
- //SPI.begin();
- //SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0));
- radio.begin();
- radio.openWritingPipe(address); // For transmitter
- radio.openReadingPipe(1, address);
- //radio.setChannel(10);
- radio.setPALevel(RF24_PA_MIN);
- delay(1000);
- }
- void loop() {
- //radio.stopListening(); // For receiver, uncomment this line
- radio.startListening();
- if (radio.available()) { // For receiver
- char text[32] = "";
- radio.read(&text, sizeof(text));
- if(text == ""){
- Serial.println(text);
- }
- }
- radio.stopListening();
- /*else { // For transmitter
- if(itterations >= 50){
- Serial.println((1 - (errors / itterations)));
- delay(5000);
- itterations = 0;
- errors = 0;
- }
- radio.stopListening();
- const char text[] = "Hello from UNO";
- bool report = radio.write(&text, sizeof(text));
- if (report) {
- Serial.println("Data sent successfully");
- } else {
- Serial.println("Sending failed");
- errors+=1;
- }
- //}*/
- delay(100);
- //itterations += 1;
- //Serial.println(itterations);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement