{"id":42,"date":"2016-01-31T21:16:00","date_gmt":"2016-01-31T21:16:00","guid":{"rendered":"http:\/\/nby.me\/?p=168"},"modified":"2020-10-03T14:43:46","modified_gmt":"2020-10-03T06:43:46","slug":"168","status":"publish","type":"post","link":"https:\/\/nby.me\/?p=42","title":{"rendered":"Arduino  UNO,Leonardo,Pro Micro,Nano \u6d4b\u8bd5nRF24L01(SI24R01)\u65b9\u6cd5"},"content":{"rendered":"<p>\u4e70\u4e8610\u4e2aSI24R01\uff0c\u60f3\u505a\u70b9\u597d\u73a9\u7684\u7528\uff0c\u4f46\u662f\u6015\u7528\u7684\u65f6\u5019\u624d\u53d1\u73b0\u6a21\u5757\u6709\u95ee\u9898\uff0c\u4e8e\u662f\u5230\u5904\u627e\u6d4b\u8bd5\u65b9\u6cd5\uff0c\u770b\u4e86\u770b\u8bba\u575b\u7684\u5e16\u5b50\uff0c\u6328\u4e2a\u8bd5\u4e86\u4e00\u6b21\u90fd\u6d4b\u8bd5\u4e0d\u901a\uff0c\u4e8e\u662f\u901a\u8fc7Google\u627e\u5230\u4e86\u4e00\u4e2a\u53ef\u4ee5\u5728Arduino UNO,Leonardo,Pro Micro,Nano\u6d4b\u8bd5\u7684\u65b9\u6cd5\u3002<!--more--><br \/>\nArduino\u7f16\u8bd1\u5668\u7248\u672c1.6.7<br \/>\n\u6e90\u5730\u5740:<a href=\"https:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo\">https:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo<\/a><br \/>\n<img decoding=\"async\" title=\"\u6a21\u5757\u56fe\" src=\"https:\/\/www.nby.me\/usr\/uploads\/2016\/01\/4081694017.jpg\" alt=\"\u6a21\u5757\u56fe\" \/><\/p>\n<p>\u5e93\u6587\u4ef6\u4e0b\u8f7d\u5730\u5740:<a href=\"https:\/\/github.com\/TMRh20\/RF24\">https:\/\/github.com\/TMRh20\/RF24<\/a><br \/>\n1 &#8211; GND<br \/>\n2 &#8211; VCC 3.3V !!! NOT 5V<br \/>\n3 &#8211; CE to Arduino pin 9 (Pro Micro 9)<br \/>\n4 &#8211; CSN to Arduino pin 10 (Pro Micro 10)<br \/>\n5 &#8211; SCK to Arduino pin 13 (Pro Micro 15)<br \/>\n6 &#8211; MOSI to Arduino pin 11 (Pro Micro 16)<br \/>\n7 &#8211; MISO to Arduino pin 12 (Pro Micro 14)<br \/>\n\u4e00\u4e2aXY\u6447\u6746\u6216\u8005\u4e24\u4e2a10K\u7535\u963b<br \/>\nGND to Arduino GND<br \/>\nVCC to Arduino +5V<br \/>\nX Pot to Arduino A0 (\u6216\u800510K\u7535\u963b\u63a5\u5730)<br \/>\nY Pot to Arduino A1 (\u6216\u800510K\u7535\u963b\u63a5\u5730)<\/p>\n<p>\u53d1\u9001\u7aef\u7a0b\u5e8f:<\/p>\n<ul>\n<li>YourDuinoStarter Example: nRF24L01 Transmit Joystick values\n<ul>\n<li>WHAT IT DOES: Reads Analog values on A0, A1 and transmits<br \/>\nthem over a nRF24L01 Radio Link to another transceiver.<\/li>\n<li>SEE the comments after &#8220;\/\/&#8221; on each line below<\/li>\n<li>CONNECTIONS: nRF24L01 Modules See:<br \/>\n<a href=\"http:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo\">http:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>1 &#8211; GND<br \/>\n2 &#8211; VCC 3.3V !!! NOT 5V<br \/>\n3 &#8211; CE to Arduino pin 9<br \/>\n4 &#8211; CSN to Arduino pin 10<br \/>\n5 &#8211; SCK to Arduino pin 13<br \/>\n6 &#8211; MOSI to Arduino pin 11<br \/>\n7 &#8211; MISO to Arduino pin 12<br \/>\n8 &#8211; UNUSED<\/p>\n<ul>\n<li>Analog Joystick or two 10K potentiometers:<\/li>\n<\/ul>\n<p>GND to Arduino GND<br \/>\nVCC to Arduino +5V<br \/>\nX Pot to Arduino A0<br \/>\nY Pot to Arduino A1<\/p>\n<ul>\n<li>V1.00 11\/26\/13<br \/>\nBased on examples at <a href=\"http:\/\/www.bajdi.com\/\">http:\/\/www.bajdi.com\/<\/a><\/li>\n<\/ul>\n<pre>Questions: terry@yourduino.com *\/\r\n\r\n\/<em>-----( Import needed libraries )-----<\/em>\/\r\n\r\ninclude\r\n\r\ninclude\r\n\r\ninclude\r\n\r\n\/<em>-----( Declare Constants and Pin Numbers )-----<\/em>\/\r\n\r\ndefine CE_PIN 9\r\n\r\ndefine CSN_PIN 10\r\n\r\ndefine JOYSTICK_X A0\r\n\r\ndefine JOYSTICK_Y A1\r\n\r\n\/\/ NOTE: the \"LL\" at the end of the constant is \"LongLong\" type\r\nconst uint64_t pipe = 0xE8E8F0F0E1LL; \/\/ Define the transmit pipe\r\n\r\n\/<em>-----( Declare objects )-----<\/em>\/\r\nRF24 radio(CE_PIN, CSN_PIN); \/\/ Create a Radio\r\n\/<em>-----( Declare Variables )-----<\/em>\/\r\nint joystick[2]; \/\/ 2 element array holding Joystick readings\r\n\r\nvoid setup() \/<strong><em><em> SETUP: RUNS ONCE <\/em><\/em><\/strong>**\/\r\n{\r\nSerial.begin(9600);\r\nradio.begin();\r\nradio.openWritingPipe(pipe);\r\n}\/\/--(end setup )---\r\n\r\nvoid loop() \/<strong><em><em> LOOP: RUNS CONSTANTLY <\/em><\/em><\/strong>**\/\r\n{\r\njoystick[0] = analogRead(JOYSTICK_X);\r\njoystick[1] = analogRead(JOYSTICK_Y);\r\n\r\nradio.write( joystick, sizeof(joystick) );\r\n\r\n}\/\/--(end main loop )---\r\n\r\n\/<em>-----( Declare User-written Functions )-----<\/em>\/\r\n\r\n\/\/NONE\r\n\/\/<strong>( THE END )<\/strong>**\r\n\r\n\u63a5\u6536\u7aef\u7a0b\u5e8f:\r\n\r\n\/* YourDuinoStarter Example: nRF24L01 Receive Joystick values<\/pre>\n<ul>\n<li>\n<pre>WHAT IT DOES: Receives data from another transceiver with\r\n\r\n2 Analog values from a Joystick or 2 Potentiometers<\/pre>\n<\/li>\n<\/ul>\n<pre>Displays received values on Serial Monitor<\/pre>\n<ul>\n<li>\n<pre>SEE the comments after \"\/\/\" on each line below<\/pre>\n<\/li>\n<li>\n<pre>CONNECTIONS: nRF24L01 Modules See:\r\n\r\n<a href=\"http:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo\">http:\/\/arduino-info.wikispaces.com\/Nrf24L01-2.4GHz-HowTo<\/a><\/pre>\n<\/li>\n<\/ul>\n<pre>1 - GND\r\n2 - VCC 3.3V !!! NOT 5V\r\n3 - CE to Arduino pin 9\r\n4 - CSN to Arduino pin 10\r\n5 - SCK to Arduino pin 13\r\n6 - MOSI to Arduino pin 11\r\n7 - MISO to Arduino pin 12\r\n8 - UNUSED<\/pre>\n<ul>\n<li>\n<pre>V1.00 11\/26\/13\r\n\r\nBased on examples at <a href=\"http:\/\/www.bajdi.com\/\">http:\/\/www.bajdi.com\/<\/a><\/pre>\n<\/li>\n<\/ul>\n<pre>Questions: terry@yourduino.com *\/\r\n\r\n\/<em>-----( Import needed libraries )-----<\/em>\/\r\n\r\ninclude\r\n\r\ninclude\r\n\r\ninclude\r\n\r\n\/<em>-----( Declare Constants and Pin Numbers )-----<\/em>\/\r\n\r\ndefine CE_PIN 9\r\n\r\ndefine CSN_PIN 10\r\n\r\n\/\/ NOTE: the \"LL\" at the end of the constant is \"LongLong\" type\r\nconst uint64_t pipe = 0xE8E8F0F0E1LL; \/\/ Define the transmit pipe\r\n\r\n\/<em>-----( Declare objects )-----<\/em>\/\r\nRF24 radio(CE_PIN, CSN_PIN); \/\/ Create a Radio\r\n\/<em>-----( Declare Variables )-----<\/em>\/\r\nint joystick[2]; \/\/ 2 element array holding Joystick readings\r\n\r\nvoid setup() \/<strong><em><em> SETUP: RUNS ONCE <\/em><\/em><\/strong>**\/\r\n{\r\nSerial.begin(9600);\r\ndelay(1000);\r\nSerial.println(\"Nrf24L01 Receiver Starting\");\r\nradio.begin();\r\nradio.openReadingPipe(1,pipe);\r\nradio.startListening();;\r\n}\/\/--(end setup )---\r\n\r\nvoid loop() \/<strong><em><em> LOOP: RUNS CONSTANTLY <\/em><\/em><\/strong>**\/\r\n{\r\nif ( radio.available() )\r\n{\r\n\r\n<code>\/\/ Read the data payload until we've received everything\r\nbool done = false;\r\nwhile (!done)\r\n{\r\n  \/\/ Fetch the data payload\r\n  done = radio.read( joystick, sizeof(joystick) );\r\n  Serial.print(\"X = \");\r\n  Serial.print(joystick[0]);\r\n  Serial.print(\" Y = \");      \r\n  Serial.println(joystick[1]);\r\n}<\/code>\r\n\r\n}\r\nelse\r\n{\r\n\r\n<code>  Serial.println(\"No radio available\");<\/code>\r\n\r\n}\r\n\r\n}\/\/--(end main loop )---\r\n\r\n\/<em>-----( Declare User-written Functions )-----<\/em>\/\r\n\r\n\/\/NONE\r\n\/\/<strong>( THE END )<\/strong>**<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e70\u4e8610\u4e2aSI24R01\uff0c\u60f3\u505a\u70b9\u597d\u73a9\u7684\u7528\uff0c\u4f46\u662f\u6015\u7528\u7684\u65f6\u5019\u624d\u53d1\u73b0\u6a21\u5757\u6709\u95ee\u9898\uff0c\u4e8e\u662f\u5230\u5904\u627e\u6d4b\u8bd5\u65b9\u6cd5\uff0c\u770b\u4e86\u770b\u8bba\u575b\u7684\u5e16\u5b50 &hellip; <a href=\"https:\/\/nby.me\/?p=42\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">Arduino  UNO,Leonardo,Pro Micro,Nano \u6d4b\u8bd5nRF24L01(SI24R01)\u65b9\u6cd5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[],"_links":{"self":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/42"}],"collection":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42"}],"version-history":[{"count":3,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":28944,"href":"https:\/\/nby.me\/index.php?rest_route=\/wp\/v2\/posts\/42\/revisions\/28944"}],"wp:attachment":[{"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nby.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}