Created
August 9, 2018 01:34
-
-
Save alvesoaj/7d10f1681d6e858d1eda090ed00fd928 to your computer and use it in GitHub Desktop.
Code to test nRF24L01 with Arduino (Transmisso)
This file contains hidden or 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
| /* | |
| * AJ Alves (aj.alves@zerokol.com) | |
| */ | |
| #include <SPI.h> | |
| #include "nRF24L01.h" | |
| #include "RF24.h" | |
| // Instantiate RF24 class with CE and CSN values | |
| RF24 radio(9, 10); | |
| // Address to devices comunicate each other (same in both) | |
| const uint64_t pipe = 0xE8E8F0F0E1LL; | |
| // A variable to hold some info | |
| boolean info = false; | |
| void setup() { | |
| // Setup serial output | |
| Serial.begin(9600); | |
| // Start RF | |
| radio.begin(); | |
| // Setup the channel to work within, number 100 | |
| radio.setChannel(100); | |
| // Open wite pipe | |
| radio.openWritingPipe(pipe); | |
| } | |
| void loop() { | |
| // it changes every interval | |
| info = !info; | |
| if (info) { | |
| Serial.print("Sending positive... "); | |
| } else { | |
| Serial.print("Sending negative... "); | |
| } | |
| // Send info over RF | |
| bool success = radio.write(&info, sizeof(boolean)); | |
| if (success) { | |
| Serial.println("sent!"); | |
| } else { | |
| Serial.println("fail!"); | |
| } | |
| // Wait 2 seconds and repeat | |
| delay(2000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment