Difference between revisions of "NRF2401 Wireless Communication"
(Created page with " <pre> #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); const byte rxAddr[6] = "00001"; char text[32] = {0}; void setup() { while (!Serial);...") |
|||
| Line 1: | Line 1: | ||
| + | |||
| + | [[File:nrf24l01_pinout1.jpg]] | ||
| + | |||
| + | [[File:nrf24l01_pinout2.jpg]] | ||
| + | |||
| + | [[File:nrf24l01_diagram.png]] | ||
Latest revision as of 09:59, 5 November 2016
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
char text[32] = {0};
void setup()
{
while (!Serial);
Serial.begin(115200);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
Serial.println("Listening!");
}
void loop()
{
if (radio.available())
{
radio.read(text, sizeof(text));
Serial.println(text);
}
}
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
byte i = 0;
char text[24] = {0};
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
Serial.begin(115200);
printf_begin();
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
Serial.println("Ready!");
}
void loop()
{
sprintf(text, "Hello World %d", i);
Serial.println(text);
radio.write(text, sizeof(text));
i++;
//radio.printDetails();
delay(1000);
}


