Differences
This shows you the differences between two versions of the page.
— |
hu:project:nrf24l01_simple [2022/04/21 15:04] () |
||
---|---|---|---|
1: | 1: | ||
+ | ====== NRF24L01 " | ||
+ | Egy egyszerű send / receive pár az NRF24L01-hez. | ||
+ | |||
+ | ===== Send ===== | ||
+ | <code c> | ||
+ | /* | ||
+ | Arduino Wireless Network - Multiple NRF24L01 Tutorial | ||
+ | == Example 01 - Servo Control / Node 00 - Potentiometer == | ||
+ | by Dejan, www.HowToMechatronics.com | ||
+ | Libraries: | ||
+ | nRF24/RF24, https:// | ||
+ | nRF24/ | ||
+ | */ | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | RF24 radio(10, 9); // nRF24L01 (CE,CSN) | ||
+ | RF24Network network(radio); | ||
+ | const uint16_t this_node = 00; // Address of this node in Octal format ( 04,031, etc) | ||
+ | const uint16_t node01 = 01; | ||
+ | void setup() { | ||
+ | SPI.begin(); | ||
+ | radio.begin(); | ||
+ | network.begin(90, | ||
+ | } | ||
+ | void loop() { | ||
+ | network.update(); | ||
+ | unsigned long potValue = analogRead(A0); | ||
+ | unsigned long angleValue = map(potValue, | ||
+ | RF24NetworkHeader header(node01); | ||
+ | bool ok = network.write(header, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Receive ===== | ||
+ | <code c> | ||
+ | /* | ||
+ | Arduino Wireless Network - Multiple NRF24L01 Tutorial | ||
+ | == Example 01 - Servo Control / Node 01 - Servo motor == | ||
+ | */ | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | RF24 radio(10, 9); // nRF24L01 (CE,CSN) | ||
+ | RF24Network network(radio); | ||
+ | const uint16_t this_node = 01; // Address of our node in Octal format ( 04,031, etc) | ||
+ | Servo myservo; | ||
+ | void setup() { | ||
+ | SPI.begin(); | ||
+ | radio.begin(); | ||
+ | network.begin(90, | ||
+ | myservo.attach(3); | ||
+ | } | ||
+ | void loop() { | ||
+ | network.update(); | ||
+ | while ( network.available() ) { // Is there any incoming data? | ||
+ | RF24NetworkHeader header; | ||
+ | unsigned long incomingData; | ||
+ | network.read(header, | ||
+ | myservo.write(incomingData); | ||
+ | } | ||
+ | } | ||
+ | </ |