{"id":6905,"date":"2019-08-08T12:41:05","date_gmt":"2019-08-08T03:41:05","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=6905"},"modified":"2022-09-09T17:24:21","modified_gmt":"2022-09-09T09:24:21","slug":"nrf24l01-rf%e6%a8%a1%e5%9d%97%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/arduino\/nrf24l01-rf-module-tutorial","title":{"rendered":"nRF24L01+ RF\u6a21\u5757\u6559\u7a0b"},"content":{"rendered":"<div class=\"\u201cthe_content_wrapper\u201d\">\n<p>\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e<a href=\"https:\/\/www.deviceplus.com\/\">DevicePlus.com<\/a>\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5669\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001-300x184.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001-238x146.jpg 238w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001-50x31.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image001-122x75.jpg 122w\" alt=\"nRF24L01+\" width=\"700\" height=\"430\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u5728\u4e0a\u4e00\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86ESP8266-01\uff08<\/span><a href=\"https:\/\/www.deviceplus.com\/how-tos\/arduino-guide\/esp8266-setup-tutorial-using-arduino\/\" target=\"_blank\" rel=\"noopener noreferrer\"><b>ESP8266 \u8bbe\u7f6e\u6559\u7a0b<\/b><\/a><span style=\"font-weight: 400;\">\uff09\u3002\u8fd9\u662f\u4e00\u6b3e\u5c0f\u5de7\u7684WiFi\u6a21\u5757\uff0c\u80fd\u591f\u8ba9\u7528\u6237\u8f7b\u677e\u5730\u4e3a\u4ed6\u4eec\u7684\u9879\u76ee\u6dfb\u52a0WiFi\u529f\u80fd\u3002\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba<\/span><b>nRF24L01+ RF \u6a21\u5757<\/b><span style=\"font-weight: 400;\">\u3002\u8be5\u6a21\u5757\u662fESP8266 ESP-01\u7684\u59ca\u59b9\u6a21\u5757\uff0c\u65e8\u5728\u8ba9\u7528\u6237\u5728\u9879\u76ee\u4e2d\u96c6\u6210\u65e0\u7ebf\u5c04\u9891\u901a\u4fe1\u529f\u80fd\u3002nRF24L01+\u548cESP8266 ESP-01\u5177\u6709\u76f8\u4f3c\u7684\u5916\u5f62\u5c3a\u5bf8\u548c\u5f15\u811a\u5e03\u5c40\uff08\u4e4d\u4e00\u770b\u751a\u81f3\u5b8c\u5168\u76f8\u540c\uff09\u3002\u4f46\u662f\u4e24\u8005\u7684\u63a7\u5236\u65b9\u5f0f\u548c\u529f\u80fd\u5b8c\u5168\u4e0d\u540c\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4f7f\u7528\u8be5RF\u6a21\u5757\u6240\u9700\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u540c\u65f6\u8fd8\u4f1a\u4ecb\u7ecd\u8be5\u6a21\u5757\u5982\u4f55\u4e0e\u5176\u4ed6RF\u6a21\u5757\u548c\u5fae\u63a7\u5236\u5668\u901a\u4fe1\u3002\u5c31\u672c\u6559\u6750\u800c\u8a00\uff0c\u6211\u4eec\u5c06\u6f14\u793a\u8be5\u6a21\u5757\u5982\u4f55\u4e0eArduino Uno\u5fae\u63a7\u5236\u5668\u76f8\u8fde\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">nRF24L01+\u57fa\u4e8eNordic Semiconductor nRF24L01+\uff0c\u662f\u4e00\u79cd\u201c\u7528\u4e8e2.4GHz ISM\uff08\u5de5\u4e1a\u3001\u79d1\u5b66\u548c\u533b\u7597\uff09\u9891\u6bb5\u7684RF\u6536\u53d1\u5668IC\u201d\u3002<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">\u89c4\u683c\u53c2\u6570:<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">2.4GHz ISM \u9891\u6bb5\u8fd0\u884c<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Vcc\u6807\u79f0\u7535\u538b\u4e3a3.3V\uff08\u8010\u538b\u8f93\u51655V\uff09<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u7247\u4e0a\u7a33\u538b<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u65e0\u7ebf\u4f20\u8f93\u901f\u7387\u4e3a250kbps\u30011Mbps\u30012Mbps<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8d85\u4f4e\u8fd0\u884c\u529f\u8017<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4f4e\u7535\u6d41\u6d88\u8017(900nAsISM\u9891\u6bb5<\/span><\/p>\n<p><span style=\"font-weight: 400;\">6\u4e2a\u6570\u636e\u901a\u9053<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u9996\u5148\uff0c\u6211\u4eec\u6765\u4ecb\u7ecd\u4ee5\u4e0b\u8be5\u6a21\u5757\u7684\u786c\u4ef6\u90e8\u5206\u3002\u4e0eESP-01\u7c7b\u4f3c\uff0c\u8be5RF\u6a21\u5757\u914d\u67094&#215;2\u516c\u5934\u63a5\u53e3\u3002\u7136\u800c\uff0c\u6a21\u5757\u7684\u5b9e\u9645\u5f15\u811a\u5e03\u5c40\u4e0eESP-01\u6a21\u5757\u4e0d\u540c\uff0c\u8fd9\u662f\u56e0\u4e3a\u8be5RF\u6a21\u5757\u5229\u7528\u4e0d\u540c\u7684\u901a\u4fe1\u534f\u8bae\u2014\u2014\u5229\u7528\u4e0d\u540c\u7684\u4e0e\u5176\u4ed6\u8bbe\u5907\u901a\u4fe1\u3002\u5982\u679c\u60a8\u60f3\u4e86\u89e3\u6709\u5173SPI\u534f\u8bae\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u6211\u4eec\u7684<\/span><a href=\"https:\/\/www.deviceplus.com\/how-tos\/arduino-guide\/arduino-communication-protocols-tutorial\/\" target=\"_blank\" rel=\"noopener noreferrer\"><b>Arduino Arduino\u901a\u4fe1\u534f\u8bae\u6559\u7a0b<\/b><\/a><span style=\"font-weight: 400;\">!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">RF\u6a21\u5757\u7684\u5f15\u811a\u5e03\u5c40\u5982\u4e0b\u56fe\u6240\u793a\u3002\u6b64\u4fe1\u606f\u6765\u6e90\u4e8e<\/span><i><span style=\"font-weight: 400;\">Addicore<\/span><\/i><span style=\"font-weight: 400;\">\u3002<\/span><\/p>\n<div id=\"attachment_5670\" class=\"wp-caption alignnone\" style=\"width: 410px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5670\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy.jpg\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy.jpg 400w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy-300x130.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy-260x112.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy-50x22.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image003-copy-150x65.jpg 150w\" alt=\"nRF24L01+\" width=\"400\" height=\"173\" aria-describedby=\"caption-attachment-5670\" \/><\/p>\n<p id=\"caption-attachment-5670\" class=\"wp-caption-text\">\u56fe1.nRF24L01+ RF\u6a21\u5757\u7684\u5f15\u811a\u8bf4\u660e\/ \u00a9Addicore<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u6839\u636e\u8bbe\u7f6e\uff0c\u8be5RF\u6a21\u5757\u5c5e\u4e8eSPI\u4ece\u5668\u4ef6\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u53ea\u80fd\u4e0e\u5177\u6709\u4e13\u7528SPI\u901a\u4fe1\u7ebf\u8def\u7684\u5668\u4ef6\u4e00\u8d77\u5de5\u4f5c\u3002\u56e0\u6b64\uff0c\u56fe\u4e2d\u663e\u793a\u7684SPI MOSI\u3001MISO\u548cSCK\uff08\u65f6\u949f\uff09\u5f15\u811a\u5fc5\u987b\u8fde\u63a5\u5230\u5fae\u63a7\u5236\u5668\u4e0a\u7684\u76f8\u5e94\u5f15\u811a\u3002\u5728Arduino\u4e0a\uff0c\u8fd9\u4e9b\u5f15\u811a\u7684\u5b9a\u4e49\u5982\u4e0b\uff1a<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">MOSI: Arduino D11<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">MISO: Arduino D12<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">SCK: Arduino D13<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">CE\u548cCSN\u5f15\u811a\u53ef\u4ee5\u8fde\u5230Arduino\u4e0a\u7684\u4efb\u4f55\u8f93\u51faGPIO\u5f15\u811a\u3002\u5728\u8f6f\u4ef6\u4e2d\uff0cSPI\u901a\u4fe1\u521d\u59cb\u5316\u65f6\u7cfb\u7edf\u4f1a\u6307\u5b9a\u8fd9\u4e9b\u5f15\u811a\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">RF\u6a21\u5757\u4e0eArduino\u4e4b\u95f4\u7684\u8fde\u63a5\u793a\u4f8b\u5982\u4e0b\uff1a<\/span><\/p>\n<div id=\"attachment_5671\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5671\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy-300x205.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy-214x146.jpg 214w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy-50x34.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image005-copy-110x75.jpg 110w\" alt=\"nRF24L01+\" width=\"700\" height=\"478\" aria-describedby=\"caption-attachment-5671\" \/><\/p>\n<p id=\"caption-attachment-5671\" class=\"wp-caption-text\">\u56fe2.CE\u548cCSN\u5f15\u811a\uff08\u56fe\u4e2d\u7684\u9ec4\u8272\u548c\u7eff\u8272\u7ebf\uff09\u53ef\u4ee5\u8fde\u81f3\u4efb\u610f\u4e24\u4e2a\u672a\u4f7f\u7528\u7684\u6570\u5b57\u5f15\u811a\u3002\u5728\u8f6f\u4ef6\u4e2d\uff0c\u60a8\u5e94\u8be5\u5728\u6784\u9020RF\u6a21\u5757\u5bf9\u8c61\u65f6\u6307\u5b9a\u8fd9\u4e9b\u5f15\u811a\u3002<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u4e3a\u4e86\u8fde\u63a5Arduino\u4e0e\u8be5\u6a21\u5757\uff0c\u6211\u4eec\u5c06\u4f7f\u7528<\/span><span style=\"font-weight: 400;\">TMRh20\u7684RF24\u5e93<\/span><span style=\"font-weight: 400;\">\u3002\u8be5\u5e93\u80fd\u591f\u65b9\u4fbf\u5730\u5c06RF\u6a21\u5757\u548cMCU\u4e4b\u95f4\u7684\u4f4e\u7ea7\u901a\u4fe1\u6253\u5305\u6210\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684C++\u7c7b\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5f00\u59cb\u4f7f\u7528\u8be5\u6a21\u5757\u4e4b\u524d\uff0c\u6211\u4eec\u5c06\u9996\u5148\u4ecb\u7ecd\u4e00\u4e9b\u80cc\u666f\u57fa\u7840\u77e5\u8bc6\u3002\u5728\u7f8e\u56fd\uff0c\u5c04\u9891\u8bbe\u5907\u80fd\u591f\u4f7f\u7528\u7684\u9891\u7387\u4ec5\u9650\u4e8eFCC\u5206\u914d\u7684\u9891\u7387\u8303\u56f4\u3002ISM\u9891\u6bb5\u662f\u4e3a\u79d1\u5b66\u548c\u533b\u7597\u4eea\u5668\u4fdd\u7559\u7684\u4e00\u4e2a\u9891\u7387\u8303\u56f4\uff0c\u6211\u4eec\u7684RF\u6a21\u5757\u5c06\u4f7f\u7528\u8be5ISM\u8303\u56f4\u5185\u7684\u9891\u7387\u8fdb\u884c\u901a\u4fe1\u3002\u4f7f\u7528RF\u6a21\u5757\u65f6\uff0c\u6211\u4eec\u65e0\u9700\u4e86\u89e3\u8fd9\u4e9b\u9891\u7387\u7684\u7ec6\u8282\u6216\u8005\u901a\u4fe1\u662f\u5982\u4f55\u5728\u8fd9\u4e9b\u9891\u7387\u4e0a\u53d1\u751f\u7684\u3002\u6211\u4eec\u5c06\u4e13\u6ce8\u4e8e\u53ef\u4ee5\u63a7\u5236\u7684\u65e0\u7ebfRF\u901a\u4fe1\u5185\u5bb9\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5982\u679c\u6eda\u52a8\u6d4f\u89c8<\/span><i><span style=\"font-weight: 400;\">RF24<\/span><\/i><span style=\"font-weight: 400;\">\u5e93\u6587\u4ef6\uff0c\u60a8\u4f1a\u6ce8\u610f\u5230\u91cc\u9762\u6709\u8bb8\u591a\u53c2\u6570\u53ef\u4ee5\u8bbe\u7f6e\u3002\u5173\u952e\u53c2\u6570\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/p>\n<ul>\n<li><b>\u4fe1\u9053\uff1a<\/b><span style=\"font-weight: 400;\">\u901a\u4fe1\u53d1\u751f\u7684\u7279\u5b9a\u9891\u7387\u4fe1\u9053\uff08\u9891\u7387\u6620\u5c04\u4e3a0\u5230125\u4e4b\u95f4\u7684\u6574\u6570)<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>\u8bfb\u53d6\u901a\u9053\uff1a<\/b><span style=\"font-weight: 400;\">\u8bfb\u53d6\u901a\u9053\u662f\u6307\u4e00\u4e2a\u552f\u4e00\u768424\u4f4d\u300132\u4f4d\u621640\u4f4d\u5730\u5740\uff0c\u6a21\u5757\u4ece\u8be5\u5730\u5740\u8bfb\u53d6\u6570\u636e<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>\u5199\u5165\u901a\u9053\uff1a<\/b><span style=\"font-weight: 400;\">\u5199\u5165\u901a\u9053\u662f\u6a21\u5757\u5199\u5165\u6570\u636e\u7684\u552f\u4e00\u5730\u5740<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>\u529f\u653e(PA)\u7ea7\u522b\uff1a<\/b><span style=\"font-weight: 400;\">PA\u7ea7\u522b\u8d1f\u8d23\u8bbe\u5b9a\u82af\u7247\u7684\u529f\u8017\uff0c\u4ece\u800c\u8bbe\u5b9a\u4f20\u8f93\u529f\u7387\u3002\u5c31\u672c\u6559\u7a0b\u800c\u8a00\uff08\u4e0eArduino\u4e00\u8d77\u4f7f\u7528\uff09\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u6700\u5c0f\u529f\u7387\u8bbe\u7f6e\u3002<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">RF24\u5e93\u6587\u6863\u9875\u9762\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5165\u95e8\u7684\u4f18\u79c0\u793a\u4f8b\u4ee3\u7801\u3002\u793a\u4f8b\u9879\u76ee\u7684\u5730\u5740\u5982\u4e0b\uff1a<\/span><span style=\"font-weight: 400;\">https:\/\/tmrh20.github.io\/RF24\/examples.html<\/span><span style=\"font-weight: 400;\"> \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5728\u201cGetting Started\u201dArduino\u4ee3\u7801\u4e2d\u67e5\u770b\u4e00\u4e0b\u4e0a\u6587\u5217\u51fa\u7684\u53c2\u6570\u662f\u5982\u4f55\u521d\u59cb\u5316\u7684\u3002\u201cGetting Started\u201d\uff08\u5165\u95e8\uff09\u4ee3\u7801\u7684\u5730\u5740\u5982\u4e0b\uff1a<\/span><\/p>\n<p><span style=\"font-weight: 400;\">https:\/\/tmrh20.github.io\/RF24\/GettingStarted_8ino-example.html<\/span><\/p>\n<p><span style=\"font-weight: 400;\">GettingStarted.ino<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>\/*\r\n\r\n* Getting Started example sketch for nRF24L01+ radios\r\n\r\n* This is a very basic example of how to send data from one node to another\r\n\r\n* Updated: Dec 2014 by TMRh20\r\n\r\n*\/\r\n\r\n#include &lt;SPI.h&gt;\r\n\r\n#include \"RF24.h\"\r\n\r\n\/****************** User Config ***************************\/\r\n\r\n\/***      Set this radio as radio number 0 or 1         ***\/\r\n\r\nbool radioNumber = 0;\r\n\r\n\/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 &amp; 8 *\/\r\n\r\nRF24 radio(7,8);\r\n\r\n\/**********************************************************\/\r\n\r\nbyte addresses[][6] = {\"1Node\",\"2Node\"};\r\n\r\n\/\/ Used to control whether this node is sending or receiving\r\n\r\nbool role = 0;\r\n\r\nvoid setup() {\r\n\r\nSerial.begin(115200);\r\n\r\nSerial.println(F(\"RF24\/examples\/GettingStarted\"));\r\n\r\nSerial.println(F(\"*** PRESS 'T' to begin transmitting to the other node\"));\r\n\r\n radio.begin();\r\n\r\n\/\/ Set the PA Level low to prevent power supply related issues since this is a\r\n\r\n\/\/ getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.\r\n\r\nradio.setPALevel(RF24_PA_LOW);\r\n\r\n \/\/ Open a writing and reading pipe on each radio, with opposite addresses\r\n\r\nif(radioNumber){\r\n\r\n  radio.openWritingPipe(addresses[1]);\r\n\r\n  radio.openReadingPipe(1,addresses[0]);\r\n\r\n}else{\r\n\r\n  radio.openWritingPipe(addresses[0]);\r\n\r\n  radio.openReadingPipe(1,addresses[1]);\r\n\r\n}\r\n\r\n \/\/ Start the radio listening for data\r\n\r\nradio.startListening();\r\n\r\n}\r\n\r\nvoid loop() {\r\n\r\n\/****************** Ping Out Role ***************************\/\r\n\r\nif (role == 1)  {\r\n\r\n \r\n\r\n  radio.stopListening();                                    \/\/ First, stop listening so we can talk.\r\n\r\n \r\n\r\n \r\n\r\n  Serial.println(F(\"Now sending\"));\r\n\r\n  unsigned long start_time = micros();                             \/\/ Take the time, and send it.  This will block until complete\r\n\r\n   if (!radio.write( &amp;start_time, sizeof(unsigned long) )){\r\n\r\n     Serial.println(F(\"failed\"));\r\n\r\n   }\r\n\r\n     \r\n\r\n  radio.startListening();                                    \/\/ Now, continue listening\r\n\r\n \r\n\r\n  unsigned long started_waiting_at = micros();               \/\/ Set up a timeout period, get the current microseconds\r\n\r\n  boolean timeout = false;                                   \/\/ Set up a variable to indicate if a response was received or not\r\n\r\n \r\n\r\n  while ( ! radio.available() ){                             \/\/ While nothing is received\r\n\r\n    if (micros() - started_waiting_at &gt; 200000 ){            \/\/ If waited longer than 200ms, indicate timeout and exit while loop\r\n\r\n        timeout = true;\r\n\r\n        break;\r\n\r\n    }     \r\n\r\n  }\r\n\r\n     \r\n\r\n  if ( timeout ){                                             \/\/ Describe the results\r\n\r\n      Serial.println(F(\"Failed, response timed out.\"));\r\n\r\n  }else{\r\n\r\n      unsigned long got_time;                                 \/\/ Grab the response, compare, and send to debugging spew\r\n\r\n      radio.read( &amp;got_time, sizeof(unsigned long) );\r\n\r\n      unsigned long end_time = micros();\r\n\r\n     \r\n\r\n      \/\/ Spew it\r\n\r\n      Serial.print(F(\"Sent \"));\r\n\r\n      Serial.print(start_time);\r\n\r\n      Serial.print(F(\", Got response \"));\r\n\r\n      Serial.print(got_time);\r\n\r\n      Serial.print(F(\", Round-trip delay \"));\r\n\r\n      Serial.print(end_time-start_time);\r\n\r\n      Serial.println(F(\" microseconds\"));\r\n\r\n  }\r\n\r\n  \/\/ Try again 1s later\r\n\r\n  delay(1000);\r\n\r\n}\r\n\r\n\/****************** Pong Back Role ***************************\/\r\n\r\nif ( role == 0 )\r\n\r\n{\r\n\r\n  unsigned long got_time;\r\n\r\n \r\n\r\n  if( radio.available()){\r\n\r\n                                                                  \/\/ Variable for the received timestamp\r\n\r\n    while (radio.available()) {                                   \/\/ While there is data ready\r\n\r\n      radio.read( &amp;got_time, sizeof(unsigned long) );             \/\/ Get the payload\r\n\r\n    }\r\n\r\n  \r\n\r\n    radio.stopListening();                                        \/\/ First, stop listening so we can talk  \r\n\r\n    radio.write( &amp;got_time, sizeof(unsigned long) );              \/\/ Send the final one back.     \r\n\r\n    radio.startListening();                                       \/\/ Now, resume listening so we catch the next packets.    \r\n\r\n    Serial.print(F(\"Sent response \"));\r\n\r\n    Serial.println(got_time);\r\n\r\n }\r\n\r\n}\r\n\r\n\/****************** Change Roles via Serial Commands ***************************\/\r\n\r\nif ( Serial.available() )\r\n\r\n{\r\n\r\n  char c = toupper(Serial.read());\r\n\r\n  if ( c == 'T' &amp;&amp; role == 0 ){     \r\n\r\n    Serial.println(F(\"*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\"));\r\n\r\n    role = 1;                  \/\/ Become the primary transmitter (ping out)\r\n\r\n \r\n\r\n }else\r\n\r\n  if ( c == 'R' &amp;&amp; role == 1 ){\r\n\r\n    Serial.println(F(\"*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\"));     \r\n\r\n     role = 0;                \/\/ Become the primary receiver (pong back)\r\n\r\n     radio.startListening();\r\n\r\n    \r\n\r\n  }\r\n\r\n}\r\n\r\n} \/\/ Loop\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u6587\u4ef6\u9876\u90e8\u7684\u4e24\u4e2aC++ #include\u6307\u4ee4\uff1a\u4e00\u4e2a\u7528\u4e8e\u5305\u542bArduino SPI\u5e93\uff08\u524d\u6587\u63d0\u5230RF\u6a21\u5757\u4f7f\u7528SPI\u4e0eArduino\u901a\u4fe1\uff09\uff0c\u53e6\u4e00\u4e2a\u7528\u4e8e\u5305\u542bRF24\u5e93\u3002<\/span><\/p>\n<p><span style=\"color: white; background-color: black;\">#include &lt;<\/span><span style=\"color: white; background-color: black;\">SPI.h&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<span style=\"color: white; background-color: black;\">#include \u201c<\/span><span style=\"color: white; background-color: black;\">RF24.h\u201d<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u6784\u9020RF24\u5bf9\u8c61\u7684\u8fd9\u884c\u4ee3\u7801\uff1a<\/span><span style=\"color: white; background-color: black;\">RF24 radio(7,8)<\/span><span style=\"font-weight: 400;\">; \u4f20\u9012\u7ed9\u6784\u9020\u51fd\u6570\u7684\u4e24\u4e2a\u53c2\u6570\u662f\u8fde\u81f3\u6a21\u5757\u7684CE\u548cCSN\u6570\u5b57\u5f15\u811a\u3002MOSI\u3001MISO\u548cSCK\u5f15\u811a\u5fc5\u987b\u5206\u522b\u662f\u6570\u5b57\u5f15\u811a11\u300112\u548c13\uff0c\u53ef\u662fCE\u548cCSN\u5f15\u811a\u53ef\u4ee5\u8fde\u63a5\u4efb\u610f\u4e24\u4e2a\u6570\u5b57\u5f15\u811a\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8bfb\u5199\u901a\u9053\u5730\u5740\u3002\u60a8\u53ef\u80fd\u731c\u5230\u4e86\uff0c\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u5730\u5740\u5728\u4e24\u4e2a\u5f7c\u6b64\u901a\u4fe1\u7684\u65e0\u7ebf\u8bbe\u5907\u4e4b\u95f4\u662f\u4e92\u6362\u7684\uff0c\u56e0\u4e3a\u4e00\u4e2a\u65e0\u7ebf\u8bbe\u5907\u7684\u5199\u5165\u901a\u9053\u662f\u53e6\u4e00\u4e2a\u7684\u8bfb\u53d6\u901a\u9053\u3002\u65e0\u7ebf\u901a\u8baf\u5730\u5740\u7684\u5927\u5c0f\u4e3a24\u4f4d\u300132\u4f4d\u621640\u4f4d\u3002\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u8fd9\u4e9b\u5730\u5740\u662f\u4eceC++\u5b57\u7b26\u4e32\u6587\u5b57\u8f6c\u6362\u800c\u6765\uff0c\u4f46\u60a8\u4e5f\u53ef\u4ee5\u4ee5\u4e8c\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u683c\u5f0f\u6307\u5b9a\u5b83\u4eec\u3002\u6bd4\u5982\uff0c\u6307\u5b9a\u4e3a\u5341\u516d\u8fdb\u5236\u768440\u4f4d\u5730\u5740\u53ef\u4ee5\u662f0xF0F0F0F0F0\u3002\u5b58\u50a8\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u5730\u5740\u65f6\uff0c\u4e00\u4e2a\u826f\u597d\u7684\u7f16\u7a0b\u5b9e\u8df5\u662f\u5c06\u4e24\u4e2a\u503c\u653e\u5728\u4e00\u4e2a\u6570\u7ec4\u4e2d\u3002\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u7684\u5730\u5740\u5b58\u50a8\u5728\u540d\u4e3a\u201c\u5730\u5740\u201d\u7684\u5b57\u8282\u6570\u7ec4\u4e2d\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728<\/span><i><span style=\"color: white; background-color: black;\">void setup()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u8bf4\u660e\u5982\u4f55\u4f7f\u7528\u5730\u5740\u901a\u9053\u53c2\u6570\u548c\u5176\u4ed6\u53c2\u6570\u521d\u59cb\u5316\u65e0\u7ebf\u8bbe\u5907\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u9996\u5148\uff0c\u7cfb\u7edf\u8c03\u7528<\/span><i><span style=\"font-weight: 400;\">RF24::begin()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u3002\u9488\u5bf9<\/span><i><span style=\"font-weight: 400;\">radio<\/span><\/i><span style=\"font-weight: 400;\">\u5bf9\u8c61\u8c03\u7528\u5176\u5b83RF24\u5e93\u4e4b\u65b9\u6cd5\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u8c03\u7528<\/span><i><span style=\"color: white; background-color: black;\">begin()<\/span><\/i> <span style=\"font-weight: 400;\">\uff0c\u8fd9\u662f\u56e0\u4e3a\u8be5\u65b9\u6cd5\u8d1f\u8d23\u521d\u59cb\u5316RF\u82af\u7247\u7684\u8fd0\u884c\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u7cfb\u7edf\u8c03\u7528<\/span><i><span style=\"color: white; background-color: black;\">RF24::setPALevel()<\/span><\/i> <span style=\"font-weight: 400;\">\u65b9\u6cd5\uff0c\u4ee5\u8bbe\u5b9a\u529f\u653e(PA)\u7ea7\u522b\u3002\u4e3a\u4e86\u6307\u5b9a\u529f\u653e\u7ea7\u522b\uff0cRF24\u5e93\u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u5e38\u6570\u503c\u3002\u66f4\u9ad8\u7684PA\u7ea7\u522b\u610f\u5473\u7740\u6a21\u5757\u53ef\u4ee5\u5b9e\u73b0\u66f4\u957f\u8ddd\u79bb\u7684\u901a\u4fe1\uff0c\u4f46\u662f\u5728\u8fd0\u884c\u671f\u95f4\u4f1a\u6d88\u8017\u66f4\u591a\u7684\u7535\u6d41\u3002\u4f5c\u4e3a\u5165\u95e8\u7a0b\u5e8f\uff0c\u6211\u4eec\u5c06<\/span><b><i>RF_24_LOW<\/i><\/b><span style=\"font-weight: 400;\">\u5e38\u6570\u4f5c\u4e3a\u4e00\u4e2a\u53c2\u6570\u4f20\u9012\u7ed9<\/span><i><span style=\"color: white; background-color: black;\">setPALevel()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\uff0c\u56e0\u4e3a\u4e24\u4e2a\u901a\u4fe1\u6a21\u5757\u4e4b\u95f4\u7684\u8ddd\u79bb\u4e0d\u4f1a\u5f88\u5927\u3002\u4e00\u822c\u6765\u8bb2\uff0c\u8be5RF\u6a21\u5757\u4e0eArduino\u677f\u914d\u5408\u4f7f\u7528\u65f6\uff0c\u6211\u4eec\u5e94\u8be5\u4fdd\u6301PA\u7ea7\u522b\u5c3d\u53ef\u80fd\u5730\u4f4e\uff0c\u4ece\u800c\u51cf\u5c11Arduino\u7a33\u538b\u7535\u6e90\u7684\u7535\u6d41\u6d88\u8017\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u521d\u59cb\u5316\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u3002\u6211\u4eec\u5df2\u7ecf\u5c06\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u5b9a\u4e49\u4e3a\u4e00\u4e9b\u5b57\u8282\u503c\u3002\u73b0\u5728\uff0c\u6211\u4eec\u5fc5\u987b\u5c06\u8fd9\u4e9b\u5b9a\u4e49\u4f20\u9012\u7ed9<\/span><b><i>radio<\/i><\/b><span style=\"font-weight: 400;\">\u5bf9\u8c61\uff0c\u8fd9\u6837\u5b83\u624d\u4f1a\u77e5\u9053\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u5730\u5740\u3002\u7cfb\u7edf\u7528<\/span><i><span style=\"color: white; background-color: black;\">openWritingPipe()<\/span><\/i> <span style=\"font-weight: 400;\">\u65b9\u6cd5\u8bbe\u5b9a\u5199\u5165\u901a\u9053\uff1b\u7528<\/span><i><span style=\"color: white; background-color: black;\">openReadingPipe()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u8bbe\u5b9a\u8bfb\u53d6\u901a\u9053\u3002\u6253\u5f00\u5199\u5165\u548c\u8bfb\u53d6\u901a\u9053\u7684\u793a\u4f8b\u5982\u4e0b\uff1a<\/span><\/p>\n<p><i><span style=\"color: white; background-color: black;\">radio.openWritingPipe(addresses[1]);<\/span><\/i><\/p>\n<p><i><span style=\"color: white; background-color: black;\">radio.openReadingPipe(1, addresses[0]);<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u8fd8\u5fc5\u987b\u4e3a<\/span><i><span style=\"font-weight: 400;\">openReadingPipe()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4f20\u9012\u4e00\u4e2a\u989d\u5916\u7684\u6574\u6570\u53c2\u6570\uff0c\u6307\u660e\u521d\u59cb\u5316\u54ea\u4e2a\u8bfb\u53d6\u901a\u9053\u3002\u8fd9\u662f\u56e0\u4e3aRF\u6a21\u5757\u5728\u7ed9\u5b9a\u65f6\u95f4\u6700\u591a\u53ef\u4ee5\u6253\u5f006\u4e2a\u8bfb\u53d6\u901a\u9053\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u793a\u4f8b\u4ee3\u7801\u901a\u8fc7\u4e00\u4e2a<\/span><i><span style=\"font-weight: 400;\">role<\/span><\/i><span style=\"font-weight: 400;\">\u5e03\u5c14\u503c\u6765\u9002\u5f53\u5206\u914d\u8bfb\u53d6\u548c\u5199\u5165\u901a\u9053\u503c\u3002\u6839\u636e<\/span><i><span style=\"font-weight: 400;\">role<\/span><\/i><span style=\"font-weight: 400;\">\u7684\u503c\uff0c\u7a0b\u5e8f\u786e\u5b9aRF\u6a21\u5757\u662f<\/span><i><span style=\"font-weight: 400;\">ping<\/span><\/i><span style=\"font-weight: 400;\">\u8bbe\u5907\u8fd8\u662f<\/span><i><span style=\"font-weight: 400;\">pong<\/span><\/i><span style=\"font-weight: 400;\">\u8bbe\u5907\u3002\u60a8\u7684\u5176\u4ed6\u9879\u76ee\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u4ee3\u7801\u3002\u4f46\u662f\uff0c\u8981\u786e\u4fdd\u4e24\u4e2a\u8bbe\u5907\u7684\u8bfb\u5199\u5730\u5740\u4e92\u6362\uff0c\u5426\u5219\u65e0\u6cd5\u5b9e\u73b0\u6570\u636e\u4f20\u8f93\u6216\u8bfb\u53d6\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8c03\u7528<\/span><i><span style=\"color: white; background-color: black;\">RF24::startListening()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4e4b\u540e\uff0c\u65e0\u7ebf\u6a21\u5757\u5f00\u59cb\u4fa6\u542c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6307\u793aRF\u6a21\u5757\u5f00\u59cb\u76d1\u542c\u6570\u636e\u4e4b\u524d\u5fc5\u987b\u521d\u59cb\u5316\u8bfb\u53d6\u901a\u9053\uff08\u5373\u8c03\u7528<\/span><i><span style=\"color: white; background-color: black;\">startListening()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4e4b\u524d\u5fc5\u987b\u5148\u8c03\u7528<\/span><i><span style=\"color: white; background-color: black;\">openReadingPipe()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\uff01\uff09<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u7c7b\u4f3c\u5730\uff0cRF24\u7c7b\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a<\/span><i><span style=\"color: white; background-color: black;\">stopListening()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\uff0c\u65e0\u7ebf\u6a21\u5757\u5f00\u59cb\u5199\u5165\u4e4b\u524d\u5fc5\u987b\u9996\u5148\u8c03\u7528\u8be5\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u60a8\u53ef\u80fd\u4f1a\u6ce8\u610f\u5230\u7a0b\u5e8f\u5229\u7528<\/span><i><span style=\"color: white; background-color: black;\">RF24::available()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u544a\u77e5\u65e0\u7ebf\u7535\u6a21\u5757\u68c0\u67e5\u4f20\u5165\u7684\u6570\u636e\u3002\u8fd9\u4e0e\u6211\u4eec\u4e4b\u524d\u89c1\u8fc7\u7684<\/span><i><span style=\"color: white; background-color: black;\">Serial::available()<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"color: white; background-color: black;\">SoftwareSerial::available()<\/span><\/i> <span style=\"font-weight: 400;\">\u65b9\u6cd5\u7c7b\u4f3c\u2014\u2014\u5982\u679cRF\u8fde\u63a5\u4e0a\u7684\u6570\u636e\u53ef\u7528\uff0c\u90a3\u4e48<\/span><i><span style=\"color: white; background-color: black;\">available()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u8fd4\u56de\u771f\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u8bfb\u53d6\u6570\u636e\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u6700\u540e\uff0cRF24\u7c7b\u63d0\u4f9b\u4e86\u5b9e\u9645\u6570\u636e\u5199\u5165\u548c\u8bfb\u53d6\u7684\u65b9\u6cd5\u3002<\/span><i><span style=\"color: white; background-color: black;\">RF24::write()<\/span><\/i><span style=\"font-weight: 400;\">\u4e0e<\/span><i><span style=\"color: white; background-color: black;\">RF24::read()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u7684\u53c2\u6570\u5305\u62ec\uff081\uff09\u6307\u5411\u4e0e\u4f20\u8f93\u6570\u636e\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\u7684\u6307\u9488\uff0c\u4ee5\u53ca\uff082\uff09\u4f20\u8f93\u6570\u636e\u7684\u5927\u5c0f\u3002\u5728<\/span><i><span style=\"color: white; background-color: black;\">read()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4e2d\uff0c\u6307\u9488\u6307\u5411\u7684\u53d8\u91cf\u8d1f\u8d23\u63a5\u6536\u6b63\u5728\u8bfb\u53d6\u7684\u6570\u636e\u3002\u5728<\/span><i><span style=\"color: white; background-color: black;\">write()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u4e2d\uff0c\u6307\u9488\u6307\u5411\u7684\u53d8\u91cf\u8d1f\u8d23\u4fdd\u5b58\u6b63\u5728\u5199\u5165\u7684\u6570\u636e\u3002\u5728\u8fd9\u4e24\u79cd\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u5fc5\u987b\u786e\u4fdd\u6307\u9488\u6307\u5411\u4e0e\u4f20\u8f93\u6570\u636e\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\uff0c\u5e76\u4e14\u4f20\u9012\u7ed9\u65b9\u6cd5\u7684\u5927\u5c0f\u5b9e\u9645\u4e0a\u53cd\u6620\u4e86\u6570\u636e\u7684\u5927\u5c0f\u3002\u5c06\u4e0d\u6b63\u786e\u7684\u7c7b\u578b\u6216\u5927\u5c0f\u503c\u4f20\u9012\u7ed9<\/span><i><span style=\"color: white; background-color: black;\">read()<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"color: white; background-color: black;\">write()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u53ef\u80fd\u4f1a\u4ea7\u751f\u4e0d\u5e0c\u671b\u7684\u503c\u622a\u65ad\uff0c\u4ece\u800c\u5bfc\u81f4\u4f20\u8f93\u7684\u6570\u636e\u65e0\u7528\u3002\u5728\u201cGetting Started\u201d\u4ee3\u7801\u4e2d\uff0c\u9700\u8981\u4f20\u8f93\u7684\u6570\u636e\u662f\u4e00\u4e2a<\/span><i><span style=\"font-weight: 400;\">unsigned long<\/span><\/i><span style=\"font-weight: 400;\">\u7c7b\u578b\u3002\u56e0\u6b64\uff0c\u4f20\u9012\u7ed9<\/span><i><span style=\"font-weight: 400;\">read()<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"font-weight: 400;\">write()<\/span><\/i><span style=\"font-weight: 400;\">\u65b9\u6cd5\u7684\u6307\u9488\u53c2\u6570\u4e5f\u5e94\u8be5\u6307\u5411\u4e00\u4e2a<\/span><i><span style=\"font-weight: 400;\">unsigned long<\/span><\/i><span style=\"font-weight: 400;\">\u578b\u7684\u53d8\u91cf\u3002\u5f88\u660e\u663e\uff0c\u4f20\u8f93\u6570\u636e\u7684\u5927\u5c0f\u59cb\u7ec8\u662funsigned long\u7c7b\u578b\u53d8\u91cf\u7684\u5927\u5c0f\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5927\u5c0f\u5e76\u4e0d\u9700\u8981\u7528\u4e00\u4e2a\u6574\u6570\u8fdb\u884c\u4f20\u9012\uff0c\u5927\u5c0f\uff08size\uff09\u53c2\u6570\u53ef\u4ee5\u7b80\u5355\u5730\u5199\u4e3a<\/span><b><i>sizeof(unsigned long)<\/i><\/b><span style=\"font-weight: 400;\">\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u201cGetting Started\u201d\uff08\u5165\u95e8\uff09\u4ee3\u7801\u4e2d\u552f\u4e00\u6ca1\u6709\u6d89\u53ca\u7684\u53c2\u6570\u662f\u4fe1\u9053\uff08communication channel\uff09\u3002\u5982\u679c\u9700\u8981\u6307\u5b9a\u5177\u4f53\u4fe1\u9053\uff08\u6bd4\u5982\u60a8\u6709\u591a\u4e2aRF\u7f51\u7edc\uff0c\u4e0d\u5e0c\u671b\u5f7c\u6b64\u5e72\u6270\uff09\uff0c\u90a3\u4e48\u53ef\u4ee5\u5c06\u4e00\u4e2a8\u4f4d\u7684\u6574\u6570\u53c2\u6570\u4f20\u9012\u7ed9<\/span><i><span style=\"color: white; background-color: black;\">RF24::setChannel()<\/span><\/i> <span style=\"font-weight: 400;\">\u65b9\u6cd5\uff0c\u4ee5\u8bbe\u7f6e\u4fe1\u9053\u3002\u5176\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a<\/span><i><span style=\"color: white; background-color: black;\">radio.setChannel(10)<\/span><\/i><span style=\"font-weight: 400;\">; \u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8bf7\u5c06\u4e24\u4e2aRF\u6a21\u5757\u8fde\u5230\u4e24\u4e2a\u72ec\u7acb\u7684Arduino\u677f\u4e0a\uff0c\u5e76\u4e14\u90fd\u4e0a\u4f20\u201cGetting Started\u201d\uff08\u5165\u95e8\uff09\u4ee3\u7801\uff08\u60a8\u5fc5\u987b\u5c06\u5176\u4e2d\u4e00\u5757\u677f\u7684<\/span><i><span style=\"font-weight: 400;\">role<\/span><\/i><span style=\"font-weight: 400;\">\u5e03\u5c14\u503c\u6539\u4e3a1\uff09\u3002\u60a8\u73b0\u5728\u5e94\u8be5\u80fd\u591f\u6839\u636e\u76f8\u5e94\u7684ping\u65f6\u95f4\u53d1\u9001\u6d88\u606f\u5e76\u4e14\u63a5\u6536\u8fd4\u56de\u7684\u6d88\u606f\u4e86\uff01\u4e0b\u56fe\u662f\u201cping\u201d\u548c\u201cpong\u201d\u4e24\u4e2a\u4e32\u53e3\u76d1\u89c6\u5668\u7684\u5e76\u6392\u622a\u56fe\uff1a<\/span><\/p>\n<div id=\"attachment_5672\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5672\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007-300x129.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007-260x111.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007-50x21.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/04\/image007-150x64.jpg 150w\" alt=\"nRF24L01+\" width=\"700\" height=\"300\" aria-describedby=\"caption-attachment-5672\" \/><\/p>\n<p id=\"caption-attachment-5672\" class=\"wp-caption-text\">\u56fe3.\u5de6\uff1a\u201cping\u201d\u76d1\u89c6\u5668\u8bed\u53e5\uff08\u8bbe\u59071\uff09\uff1b\u53f3\uff1a\u201cpong\u201d\u76d1\u89c6\u5668\u8bed\u53e5\uff08\u8bbe\u59070\uff09<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u606d\u559c\u60a8\u5b8c\u6210nRF24L01+\u6559\u7a0b\u7684\u5b66\u4e60\uff01\u60a8\u73b0\u5728\u5df2\u7ecf\u638c\u63e1\u4e86\u4f7f\u7528\u8fd9\u4e9b\u6f02\u4eaeRF\u6a21\u5757\u7814\u53d1\u76f8\u5173\u9879\u76ee\u7684\u6280\u80fd\u548c\u77e5\u8bc6\u4e86\uff01\u8981\u4e86\u89e3\u6d89\u53ca\u8fd9\u4e9bRF\u6a21\u5757\u7684\u9879\u76ee\uff0c\u60a8\u53ef\u4ee5\u6d4f\u89c8Device Plus\u535a\u5ba2\uff01<\/span><\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/micro.wfjydl.com\/deviceplus\/wp-content\/uploads\/2019\/03\/Rahul-Iyer.png\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\" width=\"64\" height=\"64\" \/><\/div>\n<div class=\"desc-wrapper\">\n<h5>Rahul Iyer<\/h5>\n<div class=\"desc\">\n<p>Rahul\u662f\u52a0\u5dde\u5927\u5b66\u6d1b\u6749\u77f6\u5206\u6821\u7535\u6c14\u5de5\u7a0b\u5b66\u9662\u7684\u5b66\u751f\uff0c\u7231\u597d\u7535\u5b50\u548c\u673a\u5668\u4eba\u9879\u76ee\uff0c\u5c24\u5176\u70ed\u8877\u4e8e\u7535\u52a8\u6c7d\u8f66\u6280\u672f\u548c\u8f85\u52a9\u673a\u5668\u4eba\u6280\u672f\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8eDevicePlus.com\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002 \u5728\u4e0a\u4e00\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86ESP8266-01\uff08ESP8266 \u8bbe\u7f6e\u6559\u7a0b\uff09\u3002\u8fd9\u662f\u4e00\u6b3e\u5c0f\u5de7\u7684WiFi\u6a21\u5757\uff0c\u80fd\u591f\u8ba9\u7528\u6237\u8f7b\u677e\u5730\u4e3a\u4ed6\u4eec\u7684\u9879\u76ee\u6dfb\u52a0WiFi\u529f\u80fd\u3002\u4eca\u5929\uff0c\u6211 [&hellip;]","protected":false},"author":3,"featured_media":20707,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1130],"tags":[],"class_list":["post-6905","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/6905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/comments?post=6905"}],"version-history":[{"count":6,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/6905\/revisions"}],"predecessor-version":[{"id":16396,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/6905\/revisions\/16396"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/20707"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=6905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=6905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=6905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}