-
-
Save yarogniew/7682c2a6deedc0efe93911e01b9512b0 to your computer and use it in GitHub Desktop.
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
// Nadajnik Nano | |
#include <SPI.h> | |
#include "RF24.h" | |
float msg[3] = {33.33, 66.66, 99.99}; | |
RF24 radio(7, 8); | |
byte request = 0; | |
byte addresses[][6] = {"1Node", "2Node"}; // 1Node - odbiornik, 2Node - nadajnik | |
void setup(void) { | |
Serial.begin(115200); | |
radio.begin(); | |
radio.setChannel(2); | |
radio.setPayloadSize(16); | |
radio.setDataRate(RF24_250KBPS); | |
radio.setPALevel(RF24_PA_HIGH); | |
radio.openWritingPipe(addresses[1]); | |
radio.openReadingPipe(1, addresses[0]); | |
radio.startListening(); // słuchamy | |
} | |
void loop(void) { | |
radio.startListening(); // słuchamy | |
if (radio.available()) { | |
radio.read(&request, sizeof(request)); | |
delay(30); | |
Serial.println(request); | |
if(request){ | |
radio.stopListening(); | |
Serial.println("send ..."); | |
radio.write(&msg, sizeof(msg)); | |
request = 0;} | |
} | |
//Serial.println(request); | |
//delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment