04-25-2022, 08:43 AM
(This post was last modified: 04-25-2022, 08:47 AM by KinCony Support.)
[Arduino IDE demo source code for KC868-A6]--#01-nRF24L01_code
Receive code
Transmitter code
1.nRF24L01.zip (Size: 1.5 KB / Downloads: 296)
KC868-A6_pin_define.txt (Size: 421 bytes / Downloads: 272)
Receive code
Code:
/*Receive code*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 22
#define CSN_PIN 5
const uint64_t id = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
#define SIZE 32 // this is the maximum for this example. (minimum is 1)
char buffer[SIZE + 1]; // for the RX node
uint8_t counter = 0; // for counting the number of received payloads
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println("Nrf24L01 Receiver Starting");
radio.begin();
radio.openReadingPipe(1,id);
radio.startListening();;
}
void loop()
{
if (radio.available()) { // is there a payload?
radio.read(&buffer, SIZE); // fetch payload from FIFO
Serial.print("Received:");
Serial.print(buffer); // print the payload's value
Serial.print(" - ");
Serial.println(counter++); // print the received counter
}
}
Transmitter code
Code:
/*Transmitter code*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 22
#define CSN_PIN 5
const uint64_t abc = 0xE8E8F0F0E1LL;
RF24 radio(CE_PIN, CSN_PIN);
char data[] = "Hello World, KinCony";
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(abc);
}
void loop()
{
radio.write( data, sizeof(data) );
}
1.nRF24L01.zip (Size: 1.5 KB / Downloads: 296)
KC868-A6_pin_define.txt (Size: 421 bytes / Downloads: 272)