nRF24L01+ Basic Control LED (Arduino)

Parts List
  • nRF24L01+
  • Arduino UNO
Library

nRF24L01 Library
RF24 Library

Wiring

Wire nRF24L01+ to Arduino UNO

GND <–> GND
VCC <–> Arduino 3.3V
CE <–> Arduino pin 9
CSN <–> Arduino pin 10
SCK <–> Arduino pin 13
MOSI <–> Arduino pin 11
MISO <–> Arduino pin 12

nRF24L01_LED_Arduino_UNO_TX_Elec-Cafe

nRF24L01_LED_Arduino_UNO_RX_Elec-Cafe

Code

Upload Code to TX

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int SW1 = 7;

void setup(void){
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);}

void loop(void){
if (digitalRead(SW1) == HIGH){
msg[0] = 111;
radio.write(msg, 1);}}

 

Upload Code to RX

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int msg[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
int LED1 = 3;

void setup(void){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(LED1, OUTPUT);}

void loop(void){
if (radio.available()){
bool done = false;
while (!done){
done = radio.read(msg, 1);
Serial.println(msg[0]);
if (msg[0] == 111){delay(10);digitalWrite(LED1, HIGH);}
else {digitalWrite(LED1, LOW);}
delay(10);}}
else{Serial.println("No radio available");}}