NRF24L01 PART-1 || SERIAL COMMUNICATION
CIRCUIT DIAGRAM:
COMPONENTS REQUIRED:
1. ARDUINO NANO(2).
2. NRF24L01 (2).
3. BATTERIES(2).
TRANSMITTER CODE:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "mkinventions100";
void setup() {
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World! This is Madhan";//print only 32 characters
radio.write(&text, sizeof(text));
delay(1000);
}
RECEIVER CODE:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[10] = "mkinventions100";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MIN);
radio.startListening();
}
void loop() {
if (radio.available()) {
char text[32] = "";//print only 32 characters
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
0 Comments
Please do not Enter any Spam Link in the Comment Box
Emoji