Created
November 19, 2018 02:50
-
-
Save danjperron/1056b1a57e19bb1cf9efd024379fb129 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
#include <SPI.h> | |
#include "nRF24L01.h" | |
#include "RF24.h" | |
#include "printf.h" | |
#define UNIT 0XF0F0F0F0D2LL | |
#define MASTER 0xF0F0F0F0E1LL | |
#define RELAY_ACTIVE_LOW LOW | |
#define RELAY_ACTIVE_HIGH HIGH | |
RF24 radio(8, 10); | |
const uint64_t pipe[2] = { MASTER,UNIT}; | |
int Relay1 = 2; | |
int DataMsg[1]; | |
void setup() | |
{ | |
pinMode(Relay1, OUTPUT); | |
printf_begin(); | |
Serial.begin(57600); | |
radio.begin(); | |
radio.setChannel(76); // par 76 par defaux | |
radio.setRetries(15,15); | |
radio.setAutoAck(1); | |
radio.enableDynamicPayloads(); | |
radio.enableAckPayload(); | |
radio.openReadingPipe(1, pipe[1]); | |
radio.openWritingPipe(pipe[0]); | |
radio.startListening(); | |
radio.printDetails(); | |
} | |
void loop() { | |
if (radio.available()) | |
{ | |
if( radio.read(DataMsg, 1)) | |
{ | |
Serial.print("NRF24L01 Receiver: "); | |
Serial.println(DataMsg[0]); | |
digitalWrite(Relay1,DataMsg[0]==0 ? RELAY_ACTIVE_LOW : RELAY_ACTIVE_HIGH); | |
} | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment