Browse Source

Added hello world transmitter and recevier code based on RF24 lib

lukas
Lukas Reichwein 2 years ago
parent
commit
71ebfb32fd
  1. 1
      .gitignore
  2. 27
      Arduino/receiver_code/receiver_code.ino
  3. 22
      Arduino/transmitter_code/transmitter_code.ino

1
.gitignore

@ -0,0 +1 @@
Arduino/libraries/*

27
Arduino/receiver_code/receiver_code.ino

@ -0,0 +1,27 @@
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(3, 2); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.print("recieved: ");
Serial.println(text);
}
}

22
Arduino/transmitter_code/transmitter_code.ino

@ -0,0 +1,22 @@
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(3, 2); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
}
Loading…
Cancel
Save