EasyManuals Logo

Arduino NRF24L01 User Manual

Arduino NRF24L01
14 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #10 background imageLoading...
Page #10 background image
Receiver Code
1./*
2.* Arduino Wireless Communication Tutorial
3.* Example 2 - Receiver Code
4.*
5.* by Dejan Nedelkovski, www.HowToMechatronics.com
6.*
7.* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
8.*/
9.#include <SPI.h>
10.#include <nRF24L01.h>
11.#include <RF24.h>
12.#include <Servo.h>
13.#define button 4
14.RF24 radio(7, 8); // CE, CSN
15.const byte addresses[][6] = {"00001", "00002"};
16.Servo myServo;
17.boolean buttonState = 0;
18.void setup() {
19.pinMode(button, INPUT);
20.myServo.attach(5);
21.radio.begin();
22.radio.openWritingPipe(addresses[0]); // 00002
23.radio.openReadingPipe(1, addresses[1]); // 00001
24.radio.setPALevel(RF24_PA_MIN);
25.}
26.void loop() {
27.delay(5);
28.radio.startListening();
29.if ( radio.available()) {
30.while (radio.available()) {
31.int angleV = 0;
32.radio.read(&angleV, sizeof(angleV));
33.myServo.write(angleV);
34.}
35.delay(5);
36.radio.stopListening();
37.buttonState = digitalRead(button);
38.radio.write(&buttonState, sizeof(buttonState));
39.}
40.}

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino NRF24L01 and is the answer not in the manual?

Arduino NRF24L01 Specifications

General IconGeneral
Maximum Data Rate2 Mbps
Number of Channels125
InterfaceSPI
Data Rate250kbps, 1Mbps, 2Mbps
Operating Voltage1.9V - 3.6V
Current Consumption11.3mA transmitting, 12.3mA receiving
RangeUp to 100 meters (open space)
Dimensions15mm x 29mm

Related product manuals