Description: Two RF-Nanos are connected via radio frequency. When a push-button is pressed the data is sent with radio waves to the other which turns an LED either On or Off.
Supplies:
1 – Breadboard 830 Points
2 – RF-Nanos >> Link <<
1 – Push-Button
1 – LED
1 – 10k Ohm Resistor
1 – 220 Ohm Resistor
Arduino Code:
// Transmitter(TX) Code: #include “nRF24L01.h” //NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24 #include “RF24.h” #include “SPI.h” int button = 2; int status = false; int SentMessage[1] = {000}; RF24 radio(9,10); const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between the two RF-Nanos void setup() { pinMode(button, INPUT); radio.begin(); radio.openWritingPipe(pipe); // ready to transmit } void loop() { if (digitalRead(button) == true) { status = !status; if (status == HIGH) { SentMessage[0] = 111; radio.write(SentMessage, 1); // Send pressed data to RF-Nano } if (status == LOW) { SentMessage[0] = 000; radio.write(SentMessage, 1); // Send pressed data to RF-Nano } while(digitalRead(button) == true); delay(10); } }
———————————————
// Receiver Code: #include “nRF24L01.h” // NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24 #include “RF24.h” #include “SPI.h” #define LED_PIN 4 int ReceivedMessage[1] = {000}; // Used to store value received by the RF-Nano RF24 radio(9,10); const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between the two RF-Nanos void setup() { radio.begin(); radio.openReadingPipe(1,pipe); // Get the RF-Nano ready to receive radio.startListening(); // Listen to see if information received pinMode(LED_PIN, OUTPUT); } void loop() { while (radio.available()) { radio.read(ReceivedMessage, 1); // Read information from the RF-Nano if (ReceivedMessage[0] == 111) // Indicates button is pressed { digitalWrite(LED_PIN, HIGH); } else { digitalWrite(LED_PIN, LOW); } delay(2); } }
I need help to get these ..//NRF24L01 library created by TMRh20 https://github.com/TMRh20/RF24