Arduino NRF24L01 Скачать руководство пользователя страница 7

By using the “&” before the variable name we actually set an indicating of the variable that 
stores the data that we want to be sent and using the second argument we set the number
of bytes that we want to take from that variable. In this case the sizeof() function gets all 
bytes of the strings “text”. At the end of the program we will add 1 second delay.

On the other side, at the receiver, in the loop section using the radio.available() function 
we check whether there is data to be received. If that’s true, first we create an array of 32 
elements, called “text”, in which we will save the incoming data.

1.void loop() {
2.if (radio.available()) {
3.char text[32] = "";
4.radio.read(&text, sizeof(text));
5.Serial.println(text);
6.}
7.}

Using the radion.read() function we read and store the data into the “text” variable. At the 
end we just print text on the serial monitor. So once we upload both programs, we can run 
the serial monitor at the receiver and we will notice the message “Hello World” gets printed
each second.

Arduino Wireless Bi-directional Communication

Let’s see the second example, a bi-directional wireless communication between two 
Arduino boards. Here’s the circuit schematics:

You can get the components needed for this example from the links below:

NRF24L01 Transceiver Module…………. 

Amazon

 / 

DealExtreme

Содержание NRF24L01

Страница 1: ...le Hello World message from one Arduino to another and in the second example we will have a bi directional communication between the Arduino boards where using the Joystick at the first Arduino we wil...

Страница 2: ...ch unit can communicate with up to 6 other units at the same time The power consumption of this module is just around 12mA during transmission which is even lower than a single LED The operating volta...

Страница 3: ...used for setting the module in standby or active mode as well as for switching between transmit or command mode The last pin is an interrupt pin which doesn t have to be used So once we connect the NR...

Страница 4: ...al 3 Example 1 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 RF2...

Страница 5: ...rh20 RF24 8 9 include SPI h 10 include nRF24L01 h 11 include RF24 h 12 RF24 radio 7 8 CE CSN 13 const byte address 6 00001 14 void setup 15 Serial begin 9600 16 radio begin 17 radio openReadingPipe 0...

Страница 6: ...t the same address and in that way we enable the communication between the two modules 1 radio openReadingPipe 0 address Then using the radio setPALevel function we set the Power Amplifier level in ou...

Страница 7: ...ments called text in which we will save the incoming data 1 void loop 2 if radio available 3 char text 32 4 radio read text sizeof text 5 Serial println text 6 7 Using the radion read function we read...

Страница 8: ...Joystick Module Amazon Arduino Board Amazon Servo Motor Amazon Pushbutton Amazon LED Amazon...

Страница 9: ...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 setP...

Страница 10: ...1 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 address...

Страница 11: ...d the data to the receiver 1 radio stopListening 2 int potValue analogRead A0 3 int angleValue map potValue 0 1023 0 180 4 radio write angleValue sizeof angleValue On the other side using the radio st...

Страница 12: ...but some talented people have written Arduino libraries that make them easy to us They all use the same pinout as shown in the following diagram which is a TOP VIEW Correction Here are details of the...

Страница 13: ...o 3 3V not 5 0V although the Arduino itself may run at 5 0V and the signals will be OK The NRF24L01 IC is a 3 3V device but its I O pins are 5 V tolerant which makes it easier to interface to Arduino...

Страница 14: ......

Отзывы: