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 #9 background imageLoading...
Page #9 background image
Source codes : Here are the two codes and below is the description of them.
Transmitter Code
1./*
2.* Arduino Wireless Communication Tutorial
3.* Example 2 - Transmitter 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.#define led 12
13.RF24 radio(7, 8); // CE, CSN
14.const byte addresses[][6] = {"00001", "00002"};
15.boolean buttonState = 0;
16.void setup() {
17.pinMode(12, OUTPUT);
18.radio.begin();
19.radio.openWritingPipe(addresses[1]); // 00001
20.radio.openReadingPipe(1, addresses[0]); // 00002
21.radio.setPALevel(RF24_PA_MIN);
22.}
23.void loop() {
24.delay(5);
25.radio.stopListening();
26.int potValue = analogRead(A0);
27.int angleValue = map(potValue, 0, 1023, 0, 180);
28.radio.write(&angleValue, sizeof(angleValue));
29.delay(5);
30.radio.startListening();
31.while (!radio.available());
32.radio.read(&buttonState, sizeof(buttonState));
33.if (buttonState == HIGH) {
34.digitalWrite(led, HIGH);
35.}
36.else {
37.digitalWrite(led, LOW);
38.}
39.}

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