{"id":8572,"date":"2021-02-25T00:00:57","date_gmt":"2021-02-24T15:00:57","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=8572"},"modified":"2022-03-07T17:22:04","modified_gmt":"2022-03-07T09:22:04","slug":"arduino%e9%80%9a%e4%bf%a1%e5%8d%8f%e8%ae%ae%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/tech-info\/how-tos\/arduino\/arduino-communication-protocols-tutorial","title":{"rendered":"Arduino\u901a\u4fe1\u534f\u8bae\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-4963\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001-300x201.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001-218x146.jpg 218w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001-50x34.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image001-112x75.jpg 112w\" alt=\"arduino communication\" width=\"700\" height=\"469\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4eca\u5929\uff0c\u6211\u4eec\u5c06\u8ba8\u8bbaarduino\u901a\u4fe1\u534f\u8bae\u7684\u6709\u5173\u5185\u5bb9\u3002\u8bbe\u5907\u5f80\u5f80\u9700\u8981\u76f8\u4e92\u901a\u4fe1\u4ee5\u4e2d\u7ee7\u6240\u5904\u73af\u5883\u76f8\u5173\u4fe1\u606f\uff0c\u663e\u793a\u5176\u72b6\u6001\u53d8\u5316\uff0c\u6216\u8bf7\u6c42\u6267\u884c\u8f85\u52a9\u64cd\u4f5c\u3002\u5728\u8fdb\u884c\u4efb\u4f55\u7535\u5b50\u8bbe\u5907\u7231\u597d\u76f8\u5173\u7814\u7a76\u65f6\uff0c\u60a8\u5c06\u9700\u8981\u4f7f\u7528\u591a\u4e2a\u4e0d\u540c\u7684\u4f20\u611f\u5668\u6216\u591a\u4e2a\u4e0d\u540c\u7684\u6a21\u5757\uff08\u5982ESP8266\uff09\uff0c\u5c4a\u65f6\u5fc5\u7136\u4f1a\u9047\u5230\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u6d41\u7684\u901a\u4fe1\u534f\u8bae\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f1a\u4ecb\u7ecd\u7535\u5b50\u8bbe\u5907\u4f7f\u7528\u7684\u6807\u51c6\u901a\u4fe1\u534f\u8bae\uff0c\u5e76\u4f7f\u7528Arduino Uno\u5bf9\u5176\u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e\u3002<\/span><\/p>\n<h2><b>\u4e8c\u8fdb\u5236\u6570\u5b57\u7cfb\u7edf<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u8bbe\u5907\u95f4\u7684\u901a\u4fe1\u901a\u8fc7\u6570\u5b57\u4fe1\u53f7\u8fdb\u884c\u3002\u5728\u8ba8\u8bba\u901a\u4fe1\u534f\u8bae\u4e4b\u524d\uff0c\u6211\u4eec\u5c06\u9996\u5148\u8ba8\u8bba\u5982\u4f55\u4f20\u8f93\u8fd9\u4e9b\u4fe1\u53f7\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728\u6570\u5b57\u4fe1\u53f7\u4e2d\uff0c\u6570\u636e\u7531\u4e00\u7cfb\u5217\u7684<\/span><i><span style=\"font-weight: 400;\">\u9ad8\u7535\u5e73\u5230\u4f4e\u7535\u5e73<\/span><\/i><span style=\"font-weight: 400;\">\u6216<\/span><i><span style=\"font-weight: 400;\">\u4f4e\u7535\u5e73\u5230\u9ad8\u7535\u5e73<\/span><\/i><span style=\"font-weight: 400;\">\u7684\u8109\u51b2\u8fdb\u884c\u4f20\u8f93\uff0c\u5e76\u4e14\u5207\u6362\u975e\u5e38\u8fc5\u901f\u3002\u6570\u5b57\u4fe1\u53f7\u4e2d\u7684\u9ad8\u7535\u5e73\u548c\u4f4e\u7535\u5e73\u5206\u522b\u4ee3\u88681\u548c0\uff0c\u5f53\u6309\u7167\u987a\u5e8f\u8fde\u5728\u4e00\u8d77\u65f6\uff0c\u5c31\u643a\u5e26\u4e86\u53ef\u7531\u5fae\u63a7\u5236\u5668\u7f16\u8bd1\u7684\u4fe1\u606f\u3002\u542c\u8bf4\u8fc7\u4f4d\u548c\u5b57\u8282\u5417\uff1f\u8fd9\u4e9b1\u548c0\u662f\u4f4d\uff0c\u5f53\u5b83\u4eec\u4ee58\u4e2a\u4e3a\u4e00\u7ec4\u65f6\uff0c\u5c31\u79f0\u4e4b\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u4f4d<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u5f53\u5b83\u4eec\u4ee58\u4e2a\u4e3a\u4e00\u7ec4\u65f6\uff0c\u5c31\u79f0\u4e4b\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u5b57\u8282<\/span><\/i><span style=\"font-weight: 400;\">!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4e00\u4e2a\u5b57\u8282\u770b\u8d77\u6765\u5927\u6982\u662f\u8fd9\u6837\uff1a10111001<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4e8b\u5b9e\u8bc1\u660e\uff0c\u8fd9\u4e2a\u75318\u4f4d\u7ec4\u6210\u7684\u5e8f\u5217\u4ee3\u8868\u4e86\u4e00\u4e2a\u6570\u5b57\uff0c\u5c31\u50cf597\u8fd9\u4e2a\u6570\u5b57\u4ee3\u8868\u4e86<\/span><i><span style=\"font-weight: 400;\">597<\/span><\/i><span style=\"font-weight: 400;\">\u4e00\u6837\u3002\u6bcf\u4e2a\u6570\u5b57\u5360\u636e\u4e86\u4e00\u4e2a\u4f4d\u7f6e\u503c\uff0c\u8be5\u4f4d\u7f6e\u503c\u4e2d\u76841\u6216\u80050\u8868\u793a\u8be5\u4f4d\u7f6e\u503c\u88ab\u8ba1\u6570\u4e86\u591a\u5c11\u6b21\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728597\u7684\u793a\u4f8b\u4e2d\uff0c5\u8868\u793a\u67095\u4e2a100\uff0c9\u8868\u793a\u67099\u4e2a10\uff0c7\u8868\u793a\u67097\u4e2a1\u3002\u52a0\u5728\u4e00\u8d77\uff0c\u5c31\u8868\u793a5\u4e2a100+9\u4e2a10+7\u4e2a1\uff08500 + 90 + 7\uff09\u2026\u2026\u6216597\u3002\u56e0\u4e3a1\u662f10<sup>0<\/sup><\/span><span style=\"font-weight: 400;\"> \uff0c10\u662f10<sup>1<\/sup><\/span><span style=\"font-weight: 400;\">\uff0c100\u662f10<sup>2<\/sup><\/span><span style=\"font-weight: 400;\">\u7b49\u7b49\uff0c\u56e0\u6b64\u8fd9\u53eb\u505a\u57fa\u4e8e10\u7684\u7cfb\u7edf\uff01\u5728\u57fa\u4e8e10\u7684\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6570\u5b57\u7684\u53d6\u503c\u8303\u56f4\u4e3a0\u52309\uff080\u523010-1\uff09\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u73b0\u5728\u6211\u4eec\u518d\u6765\u770b10111001\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u8fd9\u662f\u57fa\u4e8e2\u7684\u7cfb\u7edf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u6570\u5b57\u7684\u53d6\u503c\u8303\u56f4\u4e3a0\u52301\u3002\u6211\u4eec\u53ef\u4ee5\u8bf4\u6bcf\u4e2a\u6570\u5b57\u90fd\u662f2\u7684\u5e42\uff0c\u8fd9\u610f\u5473\u774010111001\u5b9e\u9645\u4e3a1 * 2<\/span><span style=\"font-weight: 400;\"><sup>7<\/sup><\/span><span style=\"font-weight: 400;\"> + 0 * 2<\/span><span style=\"font-weight: 400;\"><sup>6<\/sup><\/span><span style=\"font-weight: 400;\"> + 1 * 2<\/span><span style=\"font-weight: 400;\"><sup>5<\/sup><\/span><span style=\"font-weight: 400;\"> + 1 * 2<\/span><span style=\"font-weight: 400;\"><sup>4<\/sup><\/span><span style=\"font-weight: 400;\"> + 1 * 2<\/span><span style=\"font-weight: 400;\"><sup>3<\/sup><\/span><span style=\"font-weight: 400;\"> + 0 * 2<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\"> + 0 * 2<\/span><span style=\"font-weight: 400;\"><sup>1<\/sup><\/span><span style=\"font-weight: 400;\"> + 1 * 2<\/span><span style=\"font-weight: 400;\"><sup>0<\/sup><\/span><span style=\"font-weight: 400;\">\uff0c\u6216\u8005\u8bf4\u4e3a\u57fa\u4e8e10\u7684\u7cfb\u7edf\u4e2d\u7684185\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u53ef\u4ee5\u60f3\u8c61\uff0c\u60a8\u53ef\u4ee5\u62e5\u6709\u57fa\u4e8e\u4efb\u4f55\u6570\u5b57\u7684\u6570\u5b57\u7cfb\u7edf\uff01\u5e38\u89c1\u7684\u4e00\u4e9b\u6570\u5b57\u4e3a2\u30018\u300110\u548c16\u3002\u4e3a\u4e86\u7b80\u5355\u8d77\u89c1\uff0c\u6570\u5b66\u5bb6\u4e3a\u8fd9\u4e9b\u5e38\u89c1\u7684\u6570\u5b57\u7cfb\u7edf\u547d\u4e86\u540d\u2014\u2014\u57fa\u4e8e2\u7684\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u4e8c\u8fdb\u5236<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u57fa\u4e8e8\u7684\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u516b\u8fdb\u5236<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u57fa\u4e8e10\u7684\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u5341\u8fdb\u5236<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u57fa\u4e8e16\u7684\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u5341\u516d\u8fdb\u5236<\/span><\/i><span style=\"font-weight: 400;\">\u3002\u6bcf\u4e2a\u6570\u5b57\u7cfb\u7edf\u90fd\u9075\u5faa\u76f8\u540c\u7684\u539f\u7406\uff1a\u6bcf\u4e2a\u6570\u5b57\u4ee3\u8868\u8be5\u57fa\u6570\u7684\u5e42\u88ab\u8ba1\u6570\u7684\u6b21\u6570\uff0c\u5e76\u4e14\u6bcf\u4e2a\u6570\u5b57\u7684\u503c\u90fd\u53ea\u80fd\u57280\u5230\uff08\u57fa\u6570-1\uff09\u4e4b\u95f4\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4e86\u89e3\u4e0d\u540c\u7684\u57fa\u6570\u7cfb\u7edf\u5f88\u6709\u7528\uff0c\u56e0\u4e3a\u5b57\u8282\u548c\u6570\u636e\u901a\u5e38\u4ee5\u4e0d\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\u8868\u8fbe\u3002\u53ef\u4ee5\u770b\u51fa\uff0c\u5199B9\uff08\u5341\u516d\u8fdb\u5236\uff09\u6bd4\u519910111001\uff08\u4e8c\u8fdb\u5236\uff09\u5bb9\u6613\u3002\u5728\u8f6f\u4ef6\u4e2d\uff0c\u4e8c\u8fdb\u5236\u6570\u4ee5<\/span><i><span style=\"font-weight: 400;\">0b<\/span><\/i><span style=\"font-weight: 400;\">\u4f5c\u4e3a\u524d\u7f00\uff0c\u516b\u8fdb\u5236\u6570\u4ee5<\/span><i><span style=\"font-weight: 400;\">0<\/span><\/i><span style=\"font-weight: 400;\">\u4f5c\u4e3a\u524d\u7f00\uff0c\u5341\u516d\u8fdb\u5236\u6570\u4ee5<\/span><i><span style=\"font-weight: 400;\">0x<\/span><\/i><span style=\"font-weight: 400;\">\u4f5c\u4e3a\u524d\u7f00\u3002\u5341\u8fdb\u5236\u6570\u6ca1\u6709\u524d\u7f00\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u77e5\u9053\u5982\u4f55\u5728\u57fa\u6570\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\u4e5f\u5f88\u6709\u7528\uff0c\u56e0\u4e3a\u4e00\u4e9b\u5f88\u9177\u7684\u6570\u5b66\u6280\u5de7\u901a\u5e38\u7528\u4e8c\u8fdb\u5236\u6570\u8fdb\u884c\u8868\u8fbe\u3002\u4f46\u662f\uff0c\u51fa\u4e8e\u672c\u6559\u7a0b\u7684\u76ee\u7684\uff0c\u6211\u4eec\u4ec5\u8bb2\u8ff0\u5230\u8fd9\u91cc\u3002\u8bf7\u67e5\u770b\u4ee5\u4e0b\u672c\u6559\u7a0b\u7684\u9644\u5f55\u6765\u83b7\u53d6\u6709\u5173\u8fd9\u4e9b\u6280\u5de7\u7684\u6587\u7ae0\uff01<\/span><\/p>\n<h2><b>3 \u79cd\u534f\u8bae\uff1aUART\uff0cSPI\u548cI<\/b><b><sup>2<\/sup><\/b><b>C<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u7535\u6c14\u5de5\u7a0b\u884c\u4e1a\u4f7f\u7528\u4e09\u79cd\u901a\u4fe1\u534f\u8bae\u5bf9\u7535\u5b50\u8bbe\u5907\u8fdb\u884c\u6807\u51c6\u5316\uff0c\u4ee5\u786e\u4fdd\u8bbe\u5907\u4e4b\u95f4\u7684\u517c\u5bb9\u6027\u3002\u5c06\u8bbe\u5907\u4ee5\u51e0\u79cd\u534f\u8bae\u4e3a\u4e2d\u5fc3\u8fdb\u884c\u6807\u51c6\u5316\uff0c\u610f\u5473\u7740\u8bbe\u8ba1\u8005\u53ef\u4ee5\u901a\u8fc7\u638c\u63e1\u6bcf\u4e2a\u901a\u4fe1\u534f\u8bae\u7684\u4e00\u4e9b\u57fa\u672c\u6982\u5ff5\u5b9e\u73b0\u4efb\u4f55\u8bbe\u5907\u4e4b\u95f4\u7684\u4ea4\u4e92\u3002UART\uff0cSPI\u548cI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u8fd9\u4e09\u79cd\u534f\u8bae\u7684\u5b9e\u73b0\u65b9\u5f0f\u4e0d\u540c\uff0c\u4f46\u90fd\u4f1a\u8fbe\u5230\u76f8\u540c\u7684\u76ee\u7684\uff1a\u5c06\u6570\u636e\u9ad8\u901f\u4f20\u8f93\u5230\u4efb\u4f55\u517c\u5bb9\u7684\u8bbe\u5907\u4e0a\u3002<\/span><\/p>\n<p><b>1. UART<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u6211\u4eec\u5c06\u8981\u4ecb\u7ecd\u7684\u7b2c\u4e00\u4e2a\u901a\u4fe1\u534f\u8bae\u662f<\/span><i><span style=\"font-weight: 400;\">\u901a\u7528\u5f02\u6b65\u6536\u53d1\u5668\uff08UART\uff09<\/span><\/i><span style=\"font-weight: 400;\">\u3002UART\u662f\u4e00\u79cd<\/span><i><span style=\"font-weight: 400;\">\u4e32\u884c\u901a\u4fe1<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u56e0\u4e3a\u6570\u636e\u662f\u4e00\u4f4d\u4e00\u4f4d\u4f9d\u6b21\u8fdb\u884c\u4f20\u8f93\u7684\uff08\u6211\u4eec\u5c06\u5728\u7a0d\u540e\u4ecb\u7ecd\uff09\u3002\u8bbe\u7f6eUART\u901a\u4fe1\u7684\u63a5\u7ebf\u975e\u5e38\u7b80\u5355\uff1a\u4e00\u6839\u7528\u4e8e\u4f20\u8f93\u6570\u636e\uff08TX\uff09\u7684\u7ebf\uff0c\u53e6\u4e00\u6839\u7528\u4e8e\u63a5\u6536\u6570\u636e\uff08RX\uff09\u7684\u7ebf\u3002\u5982\u60a8\u6240\u6599\uff0cTX\u7ebf\u7528\u4e8e\u53d1\u9001\u6570\u636e\uff0cRX\u7ebf\u7528\u4e8e\u63a5\u6536\u6570\u636e\u3002\u4f7f\u7528\u4e32\u884c\u901a\u4fe1\u7684\u8bbe\u5907\u7684TX\u7ebf\u548cRX\u7ebf\u5c06\u4e00\u8d77\u5f62\u6210\u4e00\u4e2a<\/span><i><span style=\"font-weight: 400;\">\u4e32\u884c\u7aef\u53e3<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u901a\u8fc7\u8be5\u7aef\u53e3\u53ef\u4ee5\u8fdb\u884c\u901a\u4fe1\u3002<\/span><\/p>\n<div id=\"attachment_4964\" class=\"wp-caption alignnone\" style=\"width: 608px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4964\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003.jpg\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003.jpg 598w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003-300x172.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003-255x146.jpg 255w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003-50x29.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image003-131x75.jpg 131w\" alt=\"arduino communication\" width=\"598\" height=\"342\" aria-describedby=\"caption-attachment-4964\" \/><\/p>\n<p id=\"caption-attachment-4964\" class=\"wp-caption-text\">\u56fe1\uff1aUART\u7684\u786c\u4ef6\u8fde\u63a5\u56fe<\/p>\n<\/div>\n<p><i><span style=\"font-weight: 400;\">UART<\/span><\/i><span style=\"font-weight: 400;\">\u4e00\u8bcd\u5b9e\u9645\u4e0a\u662f\u6307\u7ba1\u7406\u4e32\u884c\u6570\u636e\u6253\u5305\u548c\u8f6c\u6362\u7684\u677f\u8f7d\u786c\u4ef6\u3002\u5982\u679c\u5e0c\u671b\u8bbe\u5907\u80fd\u591f\u901a\u8fc7UART\u534f\u8bae\u8fdb\u884c\u901a\u4fe1\uff0c\u5c31\u5fc5\u987b\u5177\u6709\u8be5\u786c\u4ef6\uff01\u5728 Arduino Uno\u4e0a\uff0c\u6709\u4e00\u4e2a\u4e13\u7528\u4e8e\u4e0eArduino\u6240\u8fde\u63a5\u8ba1\u7b97\u673a\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\u7684\u4e32\u884c\u7aef\u53e3\u3002\u5bf9\uff01<\/span><i><span style=\"font-weight: 400;\">\u901a\u7528\u4e32\u884c\u603b\u7ebf<\/span><\/i><span style=\"font-weight: 400;\">USB\u6b63\u662f\u4e00\u4e2a\u4e32\u884c\u7aef\u53e3\uff01\u5728Arduino Uno\u4e0a\uff0cUSB\u7684\u8fde\u63a5\u901a\u8fc7\u677f\u8f7d\u786c\u4ef6\u914d\u7f6e\u4e3a\u6210\u4e24\u4e2a\u6570\u5b57\u5f15\u811a<\/span><i><span style=\"font-weight: 400;\">GPIO 0<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"font-weight: 400;\">GPIO 1<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u53ef\u7528\u4e8e\u6d89\u53ca\u4e0e\u8ba1\u7b97\u673a\u4ee5\u5916\u7684\u7535\u5b50\u8bbe\u5907\u8fdb\u884c\u4e32\u884c\u901a\u4fe1\u7684\u9879\u76ee\u3002<\/span><\/p>\n<div id=\"attachment_4965\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4965\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005-300x214.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005-205x146.jpg 205w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005-50x36.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image005-105x75.jpg 105w\" alt=\"arduino communication\" width=\"700\" height=\"499\" aria-describedby=\"caption-attachment-4965\" \/><\/p>\n<p id=\"caption-attachment-4965\" class=\"wp-caption-text\">\u56fe2\uff1aGPIO 0 \u548cGPIO 1\u662f\u4e32\u53e3RX\u548cTX\u3002\u4efb\u4f55GPIO\u5f15\u811a\u90fd\u53ef\u4ee5\u901a\u8fc7SoftwareSerial\u5e93\u7528\u4f5c\u4e32\u53e3RX\u6216TX\u3002<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528<\/span><i><span style=\"font-weight: 400;\">SoftwareSerial<\/span><\/i><span style=\"font-weight: 400;\"> Arduino \u5e93(SoftwareSerial.h)\u5c06\u5176\u4ed6GPIO\u5f15\u811a\u7528\u4f5c\u4e32\u53e3RX\u548cTX\u7ebf\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">UART\u4e4b\u6240\u4ee5\u6210\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u5f02\u6b65<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u662f\u56e0\u4e3a\u4e0d\u4f7f\u7528\u8bd5\u56fe\u76f8\u4e92\u901a\u4fe1\u7684\u4e24\u4e2a\u8bbe\u5907\u4e4b\u95f4\u7684\u540c\u6b65\u65f6\u949f\u4fe1\u53f7\u8fdb\u884c\u901a\u4fe1\u3002\u7531\u4e8e\u901a\u4fe1\u901f\u7387\u4e0d\u662f\u901a\u8fc7\u8fd9\u79cd\u7a33\u5b9a\u4fe1\u53f7\u5b9a\u4e49\u7684\uff0c\u201c\u53d1\u9001\u65b9\u201d\u8bbe\u5907\u65e0\u6cd5\u786e\u5b9a\u201c\u63a5\u6536\u65b9\u201d\u8bbe\u5907\u662f\u5426\u83b7\u53d6\u4e86\u6b63\u786e\u7684\u6570\u636e\u3002\u56e0\u6b64\uff0c\u8bbe\u5907\u5c06\u6570\u636e\u5206\u6210\u4e86\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\uff0c\u4ee5\u786e\u4fdd\u63a5\u6536\u5230\u7684\u6570\u636e\u4e0e\u53d1\u9001\u7684\u6570\u636e\u76f8\u540c\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">UART\u6570\u636e\u5305\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/p>\n<div id=\"attachment_4966\" class=\"wp-caption alignnone\" style=\"width: 660px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4966\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007.jpg\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007.jpg 650w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007-300x190.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007-231x146.jpg 231w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007-50x32.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image007-119x75.jpg 119w\" alt=\"arduino communication\" width=\"650\" height=\"411\" aria-describedby=\"caption-attachment-4966\" \/><\/p>\n<p id=\"caption-attachment-4966\" class=\"wp-caption-text\">\u56fe3\uff1aUART\u6570\u636e\u5305\u89c6\u56fe\/ \u00a9electric imp<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u901a\u8fc7UART\u8fdb\u884c\u901a\u4fe1\u7684\u8bbe\u5907\u4f1a\u53d1\u9001\u9884\u5b9a\u4e49\u5927\u5c0f\u7684\u6570\u636e\u5305\uff0c\u5176\u4e2d\u5305\u542b\u6709\u5173\u6d88\u606f\u7684\u5f00\u59cb\u4e0e\u7ed3\u675f\uff0c\u4ee5\u53ca\u786e\u8ba4\u6d88\u606f\u662f\u5426\u63a5\u6536\u7684\u9644\u52a0\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u4e3a\u4e86\u5f00\u59cb\u901a\u4fe1\uff0c\u53d1\u9001\u8bbe\u5907\u5c06\u53d1\u9001\u7ebf\u62c9\u4f4e\uff0c\u6307\u793a\u6570\u636e\u5305\u5f00\u59cb\u53d1\u9001\u3002\u7136\u800c\uff0c\u76ee\u524d\u9047\u5230\u7684\u95ee\u9898\u662f\uff0c\u4e0e\u540c\u6b65\u901a\u4fe1\u65b9\u5f0f\u76f8\u6bd4\uff0cUART\u901f\u5ea6\u8f83\u6162\uff0c\u56e0\u4e3a\u4f20\u8f93\u7684\u6570\u636e\u53ea\u6709\u4e00\u90e8\u5206\u7528\u4e8e\u8bbe\u5907\u7684\u5e94\u7528\u7a0b\u5e8f\uff08\u5176\u4f59\u90e8\u5206\u7528\u4e8e\u901a\u4fe1\u672c\u8eab\uff01\uff09\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728\u5927\u591a\u6570\u5d4c\u5165\u5f0f\u5e73\u53f0\uff08\u4f8b\u5982Arduino\uff09\u4e0a\u5b9e\u73b0UART\u4e32\u884c\u901a\u4fe1\u65f6\uff0c\u7528\u6237\u4e0d\u7528\u5728\u4f4d\u7684\u6570\u636e\u7ea7\u522b\u4e0a\u8fdb\u884c\u901a\u4fe1\uff0c\u5e73\u53f0\u901a\u5e38\u63d0\u4f9b\u66f4\u9ad8\u7ea7\u522b\u7684\u8f6f\u4ef6\u5e93\uff0c\u7528\u6237\u53ea\u9700\u5728\u8fd9\u4e9b\u8f6f\u4ef6\u5e93\u4e2d\u5904\u7406\u901a\u4fe1\u5185\u5bb9\u5373\u53ef\u3002\u5728Arduino\u5e73\u53f0\u4e0a\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528<\/span><i><span style=\"font-weight: 400;\">Serial<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"font-weight: 400;\">SoftwareSerial<\/span><\/i><span style=\"font-weight: 400;\">\u5e93\u4e3a\u81ea\u5df1\u7684\u9879\u76ee\u5b9e\u73b0UART\u901a\u4fe1\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4ee5\u4e0b\u662f\u6709\u5173Arduino Serial\u548cSoftwareSerial\u7684\u521d\u59cb\u5316\u548c\u4f7f\u7528\u7684C++\u7b80\u8981\u53c2\u8003\u3002<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Serial \u548c SoftwareSerial \u65b9\u6cd5\uff08method\uff09<\/b><\/td>\n<td><b>\u76ee\u7684<\/b><\/td>\n<td><b>\u4ee3\u7801<\/b><\/td>\n<td><b>\u91ca\u4e49<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Constructor (\u4ec5SoftwareSerial)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5b9a\u4e49GPIO\u5f15\u811a\u4e3aUART RX\u7ebf\u548cTX\u7ebf\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SoftwareSerial comms (2 , 3); <\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5b9a\u4e49GPIO 2 \u4e0a\u7684RX\u7ebf\u4e0eGPIO 3\u4e0a\u7684TX\u7ebf\u4e3a\u4e32\u884c\u8fde\u63a5<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">begin<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u5b9a\u4e49\u4e32\u884c\u8fde\u63a5\u7684\u6ce2\u7279\u7387\uff08\u4f20\u8f93\u901f\u5ea6\uff09\u5728\u8303\u56f44800~115200\u4e4b\u95f4<\/span><\/td>\n<td><span style=\"font-weight: 400;\">comms.begin(9600);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u201ccomms\u201d\u4e32\u884c\u7aef\u53e3\u4e0a\u7684\u901a\u4fe1\u5c06\u4ee59600\u6ce2\u7279\u7387\u7684\u901f\u5ea6\u8fdb\u884c<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">print<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u901a\u8fc7\u4e32\u884c\u8fde\u63a5\u5c06\u5b57\u8282\u6570\u636e\u8f6c\u6362\u4e3a\u53ef\u9605\u8bfb\u7684\u5b57\u7b26<\/span><\/td>\n<td><span style=\"font-weight: 400;\">comms.println(\u201cHello World\u201d);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5199\u5165\u7b49\u6548\u4e8e<\/span><i><span style=\"font-weight: 400;\">Hello World<\/span><\/i><span style=\"font-weight: 400;\"> \uff08\u53ef\u8bfb\u5b57\u7b26\uff09\u7684\u5b57\u8282<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">write<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u901a\u8fc7\u4e32\u884c\u8fde\u63a5\u5199\u5165\u539f\u59cb\u5b57\u8282\u6570\u636e<\/span><\/td>\n<td><span style=\"font-weight: 400;\">comms.write(45);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5199\u5165\u503c\u4e3a45\u7684\u5b57\u8282<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">available<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u5f53\u6570\u636e\u53ef\u901a\u8fc7\u4e32\u884c\u8fde\u63a5\u83b7\u53d6\u65f6\u8bc4\u4f30\u4e3a\u771f\uff08true\uff09<\/span><\/td>\n<td><span style=\"font-weight: 400;\">if (comms.available())<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5982\u679c\u53ef\u83b7\u53d6\u901a\u8fc7\u4e32\u884c\u8fde\u63a5\u8bfb\u53d6\u7684\u6570\u636e\uff0c\u6267\u884c<\/span><i><span style=\"font-weight: 400;\">if<\/span><\/i><span style=\"font-weight: 400;\">\u8bed\u53e5<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">read<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u8bfb\u53d6\u4ece\u4e32\u884c\u8fde\u63a5\u83b7\u5f97\u7684\u6570\u636e<\/span><\/td>\n<td><span style=\"font-weight: 400;\">comms.read();<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u4ece\u4e32\u884c\u8fde\u63a5\u8bfb\u53d6\u6570\u636e<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">\u6709\u5173UART\u901a\u4fe1\uff0c\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u8be5\u901a\u4fe1\u534f\u8bae\u4e0b\u4e00\u6b21\u53ea\u80fd\u5b9e\u73b0\u4e24\u4e2a\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u56e0\u4e3a\u8be5\u534f\u8bae\u4ec5\u53d1\u9001\u6307\u793a\u6d88\u606f\u7684\u5f00\u59cb\u3001\u6d88\u606f\u5185\u5bb9\u548c\u6d88\u606f\u7684\u7ed3\u675f\u7684\u4f4d\uff0c\u6240\u4ee5\u6ca1\u6709\u529e\u6cd5\u533a\u5206\u540c\u4e00\u6761\u7ebf\u8def\u4e0a\u7684\u591a\u4e2a\u53d1\u9001\u548c\u63a5\u6536\u8bbe\u5907\u3002\u5982\u679c\u6709\u591a\u4e2a\u8bbe\u5907\u5c1d\u8bd5\u5728\u540c\u4e00\u6761\u7ebf\u8def\u4e0a\u4f20\u8f93\u6570\u636e\uff0c\u5219\u4f1a\u53d1\u751f<\/span><i><span style=\"font-weight: 400;\">\u603b\u7ebf\u4e89\u7528<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u5e76\u4e14\u63a5\u6536\u8bbe\u5907\u5f88\u53ef\u80fd\u4f1a\u63a5\u6536\u65e0\u6cd5\u4f7f\u7528\u7684\u5783\u573e\u6570\u636e\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u6b64\u5916\uff0cUART\u662f<\/span><i><span style=\"font-weight: 400;\">\u534a\u53cc\u5de5<\/span><\/i><span style=\"font-weight: 400;\">\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5373\u4f7f\u53ef\u4ee5\u5728\u4e24\u4e2a\u65b9\u5411\u4e0a\u8fdb\u884c\u901a\u4fe1\uff0c\u4e24\u4e2a\u8bbe\u5907\u4e5f<\/span><i><span style=\"font-weight: 400;\">\u65e0\u6cd5<\/span><\/i><span style=\"font-weight: 400;\">\u540c\u4e00\u65f6\u95f4\u76f8\u4e92\u4f20\u8f93\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d\uff0c\u4e24\u4e2aArduino\u901a\u8fc7\u4e32\u884c\u8fde\u63a5\u76f8\u4e92\u901a\u4fe1\uff0c\u8fd9\u610f\u5473\u7740\u5728\u7ed9\u5b9a\u7684\u65f6\u523b\uff0c\u53ea\u6709\u5176\u4e2d\u4e00\u4e2aArduino\u53ef\u4ee5\u4e0e\u53e6\u4e00\u4e2a\u201c\u4ea4\u6d41\u201d\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u5e94\u7528\u6765\u8bf4\uff0c\u8fd9\u4e00\u7279\u70b9\u76f8\u5bf9\u6765\u8bf4\u5e76\u4e0d\u91cd\u8981\uff0c\u5e76\u4e14\u4e0d\u4f1a\u4ea7\u751f\u4e0d\u5229\u5f71\u54cd\u3002<\/span><\/p>\n<p><b>2. SPI<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u6211\u4eec\u5c06\u4ecb\u7ecd\u7684\u4e0b\u4e00\u4e2a\u901a\u4fe1\u534f\u8bae\u662f<\/span><i><span style=\"font-weight: 400;\">\u4e32\u884c\u5916\u56f4\u8bbe\u5907\u63a5\u53e3\uff08SPI\uff09<\/span><\/i><span style=\"font-weight: 400;\">\u3002SPI\u4e0eUART\u4e3b\u8981\u6709\u4ee5\u4e0b\u4e0d\u540c\u70b9\uff1a<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u540c\u6b65<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u9075\u5faa\u4e3b\u4ece\u6a21\u5f0f\uff0c\u5305\u542b\u4e00\u4e2a\u4e3b\u8bbe\u5907\u548c\u591a\u4e2a\u4ece\u8bbe\u5907<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u5e94\u7528\u4e2d\u9700\u8981\u4e24\u6761\u4ee5\u4e0a\u7684\u7ebf<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">SPI\u7684\u786c\u4ef6\u8fde\u63a5\u56fe\u7a0d\u5fae\u590d\u6742\u4e00\u4e9b\uff0c\u770b\u8d77\u6765\u50cf\u8fd9\u6837\uff1a<\/span><\/p>\n<div id=\"attachment_4967\" class=\"wp-caption alignnone\" style=\"width: 684px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4967\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009.jpg\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009.jpg 674w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009-300x131.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009-260x113.jpg 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009-50x22.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image009-150x65.jpg 150w\" alt=\"arduino communication\" width=\"674\" height=\"294\" aria-describedby=\"caption-attachment-4967\" \/><\/p>\n<p id=\"caption-attachment-4967\" class=\"wp-caption-text\">\u56fe4\uff1aSPI\u7684\u786c\u4ef6\u8fde\u63a5\u56fe<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<ul>\n<li><b><b>MOSI (\u201cMaster Out Slave In\u201d): <\/b><span style=\"font-weight: 400;\">\u4ece\u4e3b\u8bbe\u5907\u5230\u4ece\u8bbe\u5907\u7684\u6570\u636e\u4f20\u8f93\u7ebf<\/span><\/b><\/li>\n<\/ul>\n<ul>\n<li><b>SCK (\u201cClock\u201d): <\/b><span style=\"font-weight: 400;\">\u5b9a\u4e49\u4e86\u4f20\u8f93\u901f\u7387\u548c\u4f20\u8f93\u5f00\u59cb\/\u7ed3\u675f\u7279\u6027\u7684\u65f6\u949f\u7ebf<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>SS (\u201cSlave Select\u201d): <\/b><span style=\"font-weight: 400;\">\u7528\u4e8e\u4e3b\u8bbe\u5907\u9009\u62e9\u8fdb\u884c\u901a\u4fe1\u7684\u4ece\u8bbe\u5907\u7684\u7ebf<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>MISO (\u201cMaster In Slave Out\u201d):<\/b><span style=\"font-weight: 400;\">\u4ece\u8bbe\u5907\u5230\u4e3b\u8bbe\u5907\u7684\u6570\u636e\u4f20\u8f93\u7ebf<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">SPI\u7684\u7b2c\u4e00\u4e2a\u7279\u70b9\u662f\u9075\u5faa<\/span><i><span style=\"font-weight: 400;\">\u4e3b\u4ece<\/span><\/i><span style=\"font-weight: 400;\">\u6a21\u578b\u3002\u8fd9\u610f\u5473\u7740\u901a\u4fe1\u4e2d\u5c06\u4f1a\u6709\u4e00\u4e2a\u8bbe\u5907\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u4e3b\u8bbe\u5907<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u800c\u5176\u4ed6\u8bbe\u5907\u4e3a<\/span><i><span style=\"font-weight: 400;\">\u4ece\u8bbe\u5907<\/span><\/i><span style=\"font-weight: 400;\">\u3002\u5728\u8be5\u6a21\u5f0f\u4e0b\uff0c\u4f1a\u5728\u8bbe\u5907\u4e4b\u95f4\u521b\u5efa\u5c42\u6b21\u7ed3\u6784\uff0c\u4ece\u800c\u663e\u793a\u51fa\u54ea\u4e2a\u8bbe\u5907\u6709\u6548\u5730\u201c\u63a7\u5236\u201d\u4e86\u5176\u4ed6\u8bbe\u5907\u3002\u6211\u4eec\u4f1a\u5728\u9610\u8ff0\u4e00\u4e2a\u4e3b\u4ece\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u793a\u4f8b\u65f6\u7b80\u5355\u5730\u8ba8\u8bba\u4e00\u4e0b\u6b64\u4e3b\u4ece\u6a21\u578b\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u524d\u9762\u6211\u4eec\u63d0\u5230\uff0c\u591a\u4e2a\u4ece\u8bbe\u5907\u53ef\u4ee5\u8fde\u63a5\u5230\u4e00\u4e2a\u4e3b\u8bbe\u5907\u3002\u8fd9\u79cd\u7cfb\u7edf\u7684\u786c\u4ef6\u56fe\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/p>\n<div id=\"attachment_4968\" class=\"wp-caption alignnone\" style=\"width: 553px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4968\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011.jpg\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011.jpg 543w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011-300x266.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011-165x146.jpg 165w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011-50x44.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image011-85x75.jpg 85w\" alt=\"arduino communication\" width=\"543\" height=\"481\" aria-describedby=\"caption-attachment-4968\" \/><\/p>\n<p id=\"caption-attachment-4968\" class=\"wp-caption-text\">\u56fe5\uff1a\u8fde\u63a5\u5230\u4e00\u4e2a\u4e3b\u8bbe\u5907\u7684\u591a\u4e2a\u4ece\u8bbe\u5907<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">SPI\u4e0d\u9700\u8981\u4e3a\u8fde\u63a5\u5230\u4e3b\u8bbe\u5907\u7684\u6bcf\u4e2a\u4ece\u8bbe\u5907\u63d0\u4f9b\u5355\u72ec\u7684\u53d1\u9001\u7ebf\u548c\u63a5\u6536\u7ebf\u3002\u5728\u6240\u6709\u4ece\u8bbe\u5907\u548c\u4e3b\u8bbe\u5907\u4e4b\u95f4\u8fde\u63a5\u4e86\u4e00\u6761\u516c\u5171\u63a5\u6536\u7ebf\uff08<\/span><i><span style=\"font-weight: 400;\">MISO<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u548c\u4e00\u6761\u516c\u5171\u53d1\u9001\u7ebf\uff08<\/span><i><span style=\"font-weight: 400;\">MOSI<\/span><\/i><span style=\"font-weight: 400;\">\uff09\uff0c\u4ee5\u53ca\u4e00\u6761\u516c\u5171\u65f6\u949f\u7ebf\uff08<\/span><i><span style=\"font-weight: 400;\">SCK<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u3002\u4e3b\u8bbe\u5907\u901a\u8fc7\u6bcf\u4e2a\u4ece\u8bbe\u5907\u5206\u522b\u914d\u7f6e\u7684SS\u7ebf\u6765\u51b3\u5b9a\u5c06\u4e0e\u54ea\u4e2a\u4ece\u8bbe\u5907\u8fdb\u884c\u901a\u4fe1\u3002\u8fd9\u610f\u5473\u7740\u6bcf\u589e\u52a0\u4e00\u4e2a\u4e0e\u4e3b\u8bbe\u5907\u901a\u4fe1\u7684\u4ece\u8bbe\u5907\uff0c\u90fd\u9700\u8981\u5728\u4e3b\u8bbe\u5907\u4e00\u4fa7\u518d\u4f7f\u7528\u4e00\u4e2aGPIO\u5f15\u811a\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SPI\u662f<\/span><i><span style=\"font-weight: 400;\">\u540c\u6b65<\/span><\/i><span style=\"font-weight: 400;\">\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u4e3b\u8bbe\u5907\u548c\u4ece\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u4e0e<\/span><i><span style=\"font-weight: 400;\">\u4e3b\u8bbe\u5907<\/span><\/i><span style=\"font-weight: 400;\">\u5b9a\u4e49\u7684\u65f6\u949f\u4fe1\u53f7\uff08\u56fa\u5b9a\u9891\u7387\u7684\u65b9\u6ce2\uff09\u7d27\u5bc6\u76f8\u5173\u3002\u4ece\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u4e3b\u4ece\u6a21\u578b\u7684\u76f4\u63a5\u5f71\u54cd\u4e4b\u4e00\uff0c\u5373\u4e3b\u8bbe\u5907\u901a\u8fc7\u65f6\u949f\u4fe1\u53f7\u6307\u5b9a\u901a\u4fe1\u901f\u7387\u6765\u9a71\u52a8\u901a\u4fe1\uff0c\u800c\u4ece\u8bbe\u5907\u5728\u8be5\u901f\u7387\u4e0b\u8fdb\u884c\u901a\u4fe1\u6765\u54cd\u5e94\u4e3b\u8bbe\u5907\u3002\u6240\u5b9a\u4e49\u7684\u901f\u7387\u9002\u7528\u4e8e\u4e3b\u8bbe\u5907\u6240\u4e3b\u5bfc\u7684\u4efb\u4f55\u901a\u4fe1\u8fc7\u7a0b\uff08\u5728\u4ece\u8bbe\u5907\u53ef\u4ee5\u627f\u53d7\u7684\u6700\u5927\u901f\u7387\u8303\u56f4\u5185\uff09\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728SPI\u4e2d\uff0c\u65f6\u949f\u4fe1\u53f7\u7684\u4e24\u4e2a\u7279\u5f81\u51b3\u5b9a\u4e86\u6570\u636e\u4f20\u8f93\u7684\u5f00\u59cb\u548c\u7ed3\u675f\uff1a\u65f6\u949f\u6781\u6027\uff08<\/span><i><span style=\"font-weight: 400;\">CPOL<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u548c\u65f6\u949f\u76f8\u4f4d\uff08<\/span><i><span style=\"font-weight: 400;\">CPHA<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u3002<\/span><i><span style=\"font-weight: 400;\">CPOL<\/span><\/i><span style=\"font-weight: 400;\">\u662f\u6307\u65f6\u949f\u4fe1\u53f7\u7684<\/span><i><span style=\"font-weight: 400;\">\u7a7a\u95f2\u72b6\u6001<\/span><\/i><span style=\"font-weight: 400;\">\uff08\u4f4e\u7535\u5e73\u6216\u9ad8\u7535\u5e73\uff09\u3002\u4e3a\u4e86\u8282\u7701\u529f\u8017\uff0c\u8bbe\u5907\u5728\u4e0d\u4e0e\u4efb\u4f55\u4ece\u8bbe\u5907\u901a\u4fe1\u65f6\u4f1a\u5c06\u65f6\u949f\u7ebf\u7f6e\u4e8e\u7a7a\u95f2\u72b6\u6001\uff0c\u5e76\u4e14\u5728\u8be5\u7a7a\u95f2\u72b6\u6001\u4e0b\u53ef\u7528\u7684\u4e24\u4e2a\u9009\u9879\u4e3a\u4f4e\u7535\u5e73\u6216\u9ad8\u7535\u5e73\u3002<\/span><i><span style=\"font-weight: 400;\">CPHA<\/span><\/i><span style=\"font-weight: 400;\">\u662f\u6307\u65f6\u949f\u4fe1\u53f7\u7684\u8df3\u53d8\u6cbf\uff0c\u51b3\u5b9a\u4f55\u65f6\u5bf9\u6570\u636e\u8fdb\u884c\u91c7\u6837\u3002\u65b9\u6ce2\u6709\u4e24\u79cd\u8df3\u53d8\u6cbf\uff08\u4e0a\u5347\u6cbf\u548c\u4e0b\u964d\u6cbf\uff09\uff0c\u5e76\u4e14\u6839\u636eCPHA\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u5bf9\u4e0a\u5347\u6cbf\u6216\u4e0b\u964d\u6cbf\u8fdb\u884c\u91c7\u6837\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">CPOL\u548cCPHA\u6709\u56db\u79cd\u4e0d\u540c\u7684\u7ec4\u5408\u65b9\u5f0f\uff0c\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td><span style=\"font-weight: 400;\">CPHA = 0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">(\u65f6\u949f\u4fe1\u53f7\u7684\u201c\u7b2c\u4e00\u79cd\u8df3\u53d8\u6cbf\u201d)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">CPHA = 1<\/span><\/p>\n<p><span style=\"font-weight: 400;\">(\u65f6\u949f\u4fe1\u53f7\u7684\u201c\u7b2c\u4e8c\u79cd\u8df3\u53d8\u6cbf\u201d)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">CPOL = 0 <\/span><\/p>\n<p><span style=\"font-weight: 400;\">(\u7a7a\u95f2\u72b6\u6001\u4e3a0)<\/span><\/td>\n<td>\n<ul>\n<li><b>\u201cSPI \u6a21\u5f0f 0\u201d<\/b><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u65f6\u949f\u7b2c\u4e00\u6b21\u4ece0\uff08\u7a7a\u95f2\uff09\u53d8\u4e3a1\u65f6\u5f00\u59cb\u91c7\u6837\u3002<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u6570\u636e\u91c7\u6837\u53d1\u751f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0a\u5347\u6cbf(0\u21921)<\/span><\/li>\n<\/ul>\n<\/td>\n<td>\n<ul>\n<li><b>\u201cSPI \u6a21\u5f0f 1\u201d<\/b><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u65f6\u949f\u7b2c\u4e00\u6b21\u4ece0\uff08\u7a7a\u95f2\uff09\u53d8\u4e3a1\u65f6\u5f00\u59cb\u91c7\u6837\u3002<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u6570\u636e\u91c7\u6837\u53d1\u751f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0b\u964d\u6cbf (1\u21920)<\/span><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">CPOL = 1<\/span><\/p>\n<p><span style=\"font-weight: 400;\">(\u7a7a\u95f2\u72b6\u6001\u4e3a 1)<\/span><\/td>\n<td>\n<ul>\n<li><b>\u201cSPI \u6a21\u5f0f 2\u201d<\/b><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u65f6\u949f\u7b2c\u4e00\u6b21\u4ece1\uff08\u7a7a\u95f2\uff09\u53d8\u4e3a0\u65f6\u5f00\u59cb\u91c7\u6837\u3002<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u6570\u636e\u91c7\u6837\u53d1\u751f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0a\u5347\u6cbf(0\u21921)<\/span><\/li>\n<\/ul>\n<\/td>\n<td>\n<ul>\n<li><b>\u201cSPI \u6a21\u5f0f 3\u201d<\/b><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u65f6\u949f\u7b2c\u4e00\u6b21\u4ece1\uff08\u7a7a\u95f2\uff09\u53d8\u4e3a0\u65f6\u5f00\u59cb\u91c7\u6837\u3002<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u2022 \u6570\u636e\u91c7\u6837\u53d1\u751f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0b\u964d\u6cbf(1\u21920)<\/span><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">\u7ef4\u57fa\u767e\u79d1\u4ee5\u56fe\u5f62\u65b9\u5f0f\u5f88\u597d\u5730\u8868\u793a\u51fa\u4e86CPOL\u548cCPHA\u7684\u8bbe\u7f6e\u4e0e\u5176\u6240\u4f20\u8f93\u6570\u636e\u7684\u5173\u7cfb\uff01<\/span><\/p>\n<div id=\"attachment_4969\" class=\"wp-caption alignnone\" style=\"width: 440px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4969\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013.jpg\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013.jpg 430w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013-300x174.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013-251x146.jpg 251w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013-50x29.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image013-129x75.jpg 129w\" alt=\"arduino communication\" width=\"430\" height=\"250\" aria-describedby=\"caption-attachment-4969\" \/><\/p>\n<p id=\"caption-attachment-4969\" class=\"wp-caption-text\">\u56fe6\uff1aCPOL\u548cCPHA\u7684\u8bbe\u7f6e\u89c6\u56fe\/ \u00a9Wikipedia<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u73b0\u5728\uff0c\u6211\u4eec\u5c06\u91cd\u70b9\u4ecb\u7ecd\u4f7f\u7528Arduino\u4f5c\u4e3a\u4e3b\u8bbe\u5907\uff08SPI.h\uff09\u5728Arduino\u4e0a\u5b9e\u73b0SPI\u7684\u65b9\u6cd5\u3002SCK\u3001MOSI\u548cMISO\u7684SPI\u6570\u5b57\u5f15\u811a\u8fde\u63a5\u8981\u5728Arduino\u5f00\u53d1\u677f\u4e0a\u8fdb\u884c\u9884\u5b9a\u4e49\u3002\u5bf9\u4e8eArduino Uno\uff0c\u8fde\u63a5\u5982\u4e0b\uff1a<\/span><\/p>\n<ul>\n<li><b>SCK: <\/b><span style=\"font-weight: 400;\">GPIO 13 \u6216 ICSP 3<\/span><\/li>\n<li><b>MOSI: <\/b><span style=\"font-weight: 400;\">GPIO 11 \u6216 ICSP 4<\/span><\/li>\n<li><b>MISO: <\/b><span style=\"font-weight: 400;\">GPIO 12 \u6216 ICSP 1<\/span><\/li>\n<li><b><b>SS: <\/b><span style=\"font-weight: 400;\">GPIO 10<\/span><\/b><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4efb\u4f55\u6570\u5b57\u5f15\u811a\u90fd\u53ef\u4ee5\u4f5c\u4e3aSS\u5f15\u811a\u3002\u4e3a\u4e86\u9009\u62e9\u8bbe\u5907\uff0c\u8be5\u6570\u5b57\u5f15\u811a\u5fc5\u987b\u88ab\u9a71\u52a8\u4e3a\u4f4e\u7535\u5e73\u3002<\/span><\/p>\n<div id=\"attachment_4970\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4970\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015-300x214.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015-204x146.jpg 204w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015-50x36.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image015-105x75.jpg 105w\" alt=\"arduino communication\" width=\"700\" height=\"500\" aria-describedby=\"caption-attachment-4970\" \/><\/p>\n<p id=\"caption-attachment-4970\" class=\"wp-caption-text\">\u56fe7\uff1aMOSP\u3001MISO\u548cSCK\u5f15\u811a\u5206\u914d\u5728ICSP\u63a5\u5934\u4ee5\u53caGPIO 11\u3001GPIO 12 \u548cGPIO 13\u4e0a<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u4ee5\u4e0b\u662f\u6709\u5173Arduino SPI\u521d\u59cb\u5316\u548c\u4f7f\u7528\u7684C++\u7b80\u8981\u53c2\u8003\u3002<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>SPI \u65b9\u6cd5\uff08Method\uff09<\/b><\/td>\n<td><b>\u76ee\u7684<\/b><\/td>\n<td><b>\u4ee3\u7801<\/b><\/td>\n<td><b>\u91ca\u4e49<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Constructor <\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5b9a\u4e49\u65f6\u949f\u901f\u7387\u3001\u6570\u636e\u4f4d\u987a\u5e8f\uff08\u6700\u9ad8\u6709\u6548\u4f4d\u5728\u524d\u6216\u6700\u4f4e\u6709\u6548\u4f4d\u5728\u524d\uff09\u4ee5\u53caSPI\u6a21\u5f0f<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SPI.beginTransaction<br \/>\n<\/span><span style=\"font-weight: 400;\">(SPISettings(14000000, MSBFIRST, SPI_MODE0));<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5728SPI\u6a21\u5f0f0\u5b9a\u4e4914MHz\u4e0b\u7684SPI\u8fde\u63a5\uff0c\u5e76\u4ee5\u6700\u9ad8\u6709\u6548\u4f4d\u5728\u524d\u7684\u65b9\u5f0f\u8fdb\u884c\u6570\u636e\u4f20\u8f93<\/span><\/td>\n<\/tr>\n<tr>\n<td><i><span style=\"font-weight: 400;\">digitalWrite<\/span><\/i><\/td>\n<td><span style=\"font-weight: 400;\">\u9009\u62e9\u8fde\u63a5\u5230\u8be5GPIO\u5f15\u811a\u7684\u4ece\u8bbe\u5907<\/span><\/td>\n<td><span style=\"font-weight: 400;\">digitalWrite(10, LOW);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5c06GPIO\u5f15\u811a\u9a71\u52a8\u4e3a\u4f4e\u7535\u5e73\u4ee5\u9009\u62e9\u4ece\u8bbe\u5907\u3002\u7136\u540e\u5c06\u5f15\u811a\u9a71\u52a8\u4e3a\u9ad8\u7535\u5e73\u4ee5\u53d6\u6d88\u9009\u62e9\u4ece\u8bbe\u5907\u3002<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">transfer<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5c06\u5b57\u8282\u4f20\u9001\u5230\u6240\u9009\u62e9\u7684\u4ece\u8bbe\u5907<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SPI.transfer(0x00);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u53d1\u9001\u503c\u4e3a0\u7684\u5b57\u8282<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">endTransaction<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u7ed3\u675fSPI\u7a0b\u5e8f\uff08\u5e94\u5728SS\u7ebf\u4e0a\u8c03\u7528digitalWrite(high)\u4e4b\u540e\u8c03\u7528\uff09<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SPI.endTransaction();<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u7ed3\u675fSPI\u7a0b\u5e8f<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">SPI\u662f<\/span><i><span style=\"font-weight: 400;\">\u5168\u53cc\u5de5<\/span><\/i><span style=\"font-weight: 400;\">\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5373\u4f7f\u5728\u5e94\u7528\u4e2d\u53ea\u8981\u6c42\u5728\u4e00\u4e2a\u65b9\u5411\u4e0a\u8fdb\u884c\u6570\u636e\u4f20\u8f93\uff0c\u901a\u4fe1\u4e5f\u59cb\u79cd\u662f\u53cc\u5411\u8fdb\u884c\u7684\u3002SPI\u5168\u53cc\u5de5\u6570\u636e\u4f20\u8f93\u901a\u5e38\u901a\u8fc7\u79fb\u4f4d\u5bc4\u5b58\u5668\u6765\u5b9e\u73b0\u3002\uff08\u8bf7\u53c2\u9605\u9644\u5f55\u4e2d\u6709\u5173\u79fb\u4f4d\u5bc4\u5b58\u5668\u7684\u6559\u7a0b\uff01\uff09\u3002\u8fd9\u8868\u660e\u5728\u8bfb\u53d6\u4e00\u4e2a\u4f4d\u65f6\uff0c\u524d\u9762\u7684\u4f4d\u5c06\u88ab\u79fb\u52a8\u4e00\u4f4d\uff0c\u968f\u540e\uff0c\u6700\u524d\u8fb9\u7684\u4f4d\u5c06\u4f1a\u88ab\u89e6\u53d1\uff0c\u5e76\u901a\u8fc7SPI\u8fde\u63a5\u53d1\u9001\u5230\u53e6\u4e00\u53f0\u8bbe\u5907\u4e0a\uff01<\/span><\/p>\n<p><strong>3. I<sup>2<\/sup>C<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">\u5185\u90e8\u96c6\u6210\u7535\u8def\u603b\u7ebf\uff08I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\uff09\u7684\u53d1\u97f3\u4e3a\u201cI\u65b9C\u201d\uff0c\u662f\u6211\u4eec\u5728\u672c\u6559\u7a0b\u4e2d\u4ecb\u7ecd\u7684\u6700\u540e\u4e00\u4e2a\u901a\u4fe1\u534f\u8bae\u3002\u867d\u7136\u8be5\u534f\u8bae\u7684\u5b9e\u73b0\u662f\u4e09\u79cd\u534f\u8bae\u4e2d\u6700\u590d\u6742\u7684\uff0c\u4f46\u662fI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u89e3\u51b3\u4e86\u5176\u4ed6\u901a\u4fe1\u534f\u8bae\u4e2d\u5b58\u5728\u7684\u4e00\u4e9b\u95ee\u9898\uff0c\u4f7f\u5176\u5728\u67d0\u4e9b\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6bd4\u5176\u4ed6\u901a\u4fe1\u534f\u8bae\u66f4\u5177\u6709\u4f18\u52bf\u3002\u8fd9\u4e9b\u4f18\u52bf\u5305\u62ec\uff1a<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u80fd\u591f\u5b9e\u73b0\u591a\u4e2a\u4e3b\u8bbe\u5907\u4e0e\u591a\u4e2a\u4ece\u8bbe\u5907\u4e4b\u95f4\u7684\u8fde\u63a5<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u540c\u6b65\uff08\u540cSPI\uff09\uff0c\u5177\u6709\u66f4\u9ad8\u7684\u901a\u4fe1\u901f\u7387<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u7b80\u6613\u6027\uff1a\u4ec5\u9700\u8981\u4e24\u6839\u7ebf\u548c\u4e00\u4e9b\u7535\u963b\u5373\u53ef\u5b9e\u73b0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u4ece\u786c\u4ef6\u5c42\u9762\u6765\u8bf4\uff0cI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u662f\u4e00\u79cd\u4e24\u7ebf\u63a5\u53e3\u2014I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u8fde\u63a5\u4e2d\u4ec5\u9700\u8981\u7684\u4e24\u6839\u7ebf\u662f\u6570\u636e\u7ebf\uff08\u6210\u4e3a<\/span><i><span style=\"font-weight: 400;\">SDA<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u548c\u65f6\u949f\u7ebf\uff08\u79f0\u4e3a<\/span><i><span style=\"font-weight: 400;\">SCL<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u3002\u6570\u636e\u7ebf\u548c\u65f6\u949f\u7ebf\u5728\u7a7a\u95f2\u72b6\u6001\u4e0b\u88ab\u62c9\u9ad8\uff0c\u800c\u5728\u9700\u8981\u901a\u8fc7\u8fde\u63a5\u53d1\u9001\u6570\u636e\u65f6\uff0c\u8fd9\u4e9b\u7ebf\u4f1a\u901a\u8fc7\u4e00\u4e9bMOSFET\u7535\u8def\u88ab\u62c9\u4f4e\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e0d\u8ba8\u8bbaI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7535\u8def\u5185\u90e8\u7684MOSFET\u64cd\u4f5c\uff0c\u8fd9\u91cc\u9700\u8981\u8bf4\u660e\u7684\u4e00\u4e2a\u91cd\u8981\u70b9\u662f\u8be5\u7cfb\u7edf\u662f\u6f0f\u6781<\/span><i><span style=\"font-weight: 400;\">\u5f00\u8def<\/span><\/i><span style=\"font-weight: 400;\">\u7684\uff0c\u5373\u7ebf\u8def\u53ea\u80fd\u7531\u8bbe\u5907\u9a71\u52a8\u4e3a\u4f4e\u7535\u5e73\u3002\u56e0\u6b64\uff0c\u5728\u9879\u76ee\u4e2d\u4f7f\u7528I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u65f6\uff0c<\/span><i><span style=\"font-weight: 400;\">\u4e0a\u62c9\u7535\u963b<\/span><\/i><span style=\"font-weight: 400;\">\uff08\u901a\u5e38\u4e3a4.7k\u2126\uff09\u8fd9\u4e00\u6b65\u81f3\u5173\u91cd\u8981\uff0c\u4ee5\u786e\u4fdd\u5728\u7a7a\u95f2\u72b6\u6001\u4e0b\u7ebf\u8def\u786e\u5b9e\u88ab\u62c9\u9ad8\u3002<\/span><\/p>\n<div id=\"attachment_4971\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4971\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017-300x182.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017-240x146.jpg 240w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017-50x30.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image017-124x75.jpg 124w\" alt=\"arduino communication\" width=\"700\" height=\"425\" aria-describedby=\"caption-attachment-4971\" \/><\/p>\n<p id=\"caption-attachment-4971\" class=\"wp-caption-text\">\u56fe8\uff1aI<sup>2<\/sup>C\u786c\u4ef6\u8fde\u63a5\u56fe<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u5177\u6709\u5176\u72ec\u7279\u6027\uff0c\u56e0\u4e3a\u5b83\u901a\u8fc7<\/span><i><span style=\"font-weight: 400;\">\u5bfb\u5740<\/span><\/i><span style=\"font-weight: 400;\">\u89e3\u51b3\u4e86\u4e0e\u591a\u4e2a\u4ece\u8bbe\u5907\u4e4b\u95f4\u7684\u63a5\u53e3\u95ee\u9898\u3002\u4e0eSPI\u901a\u4fe1\u4e00\u6837\uff0cI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u5229\u7528\u4e3b\u4ece\u6a21\u578b\u5efa\u7acb\u4e86\u901a\u4fe1\u7684\u201c\u5c42\u6b21\u7ed3\u6784\u201d\u3002\u4f46\u662f\uff0c\u4e3b\u8bbe\u5907\u4e0d\u662f\u901a\u8fc7\u5355\u72ec\u7684\u6570\u5b57\u7ebf\u8def\u9009\u62e9\u4ece\u8bbe\u5907\uff0c\u800c\u662f\u901a\u8fc7\u4e3b\u8bbe\u5907\u4e2d\u5177\u6709\u552f\u4e00\u6027\u7684<\/span><i><span style=\"font-weight: 400;\">\u5b57\u8282\u5730\u5740<\/span><\/i><span style=\"font-weight: 400;\">\u6765\u9009\u62e9\u4ece\u8bbe\u5907\uff0c\u8fd9\u79cd\u5b57\u8282\u5730\u5740\u5927\u6982\u7c7b\u4f3c\u4e8e\u8fd9\u6837\uff1a0x1B\u3002\u8fd9\u610f\u5473\u7740\u5c06\u4ece\u8bbe\u5907\u8fde\u63a5\u5230\u4e3b\u8bbe\u5907\u4e0d\u518d\u9700\u8981\u6dfb\u52a0\u6570\u5b57\u7ebf\u8def\u3002\u53ea\u8981\u6bcf\u4e2a\u4ece\u8bbe\u5907\u90fd\u6709\u552f\u4e00\u6027\u7684\u5730\u5740\uff0c\u5e94\u7528\u7a0b\u5e8f\u5c31\u53ef\u4ee5\u533a\u5206\u8fd9\u4e9b\u5730\u5740\u6240\u5bf9\u5e94\u7684\u4ece\u8bbe\u5907\u3002\u60a8\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u5730\u5740\u89c6\u4e3a\u540d\u79f0\u3002\u8981\u8c03\u7528\u4ece\u8bbe\u5907\u7684\u529f\u80fd\uff0c\u4e3b\u8bbe\u5907\u4ec5\u8c03\u7528\u5176\u540d\u79f0\u5373\u53ef\uff0c\u800c<\/span><i><span style=\"font-weight: 400;\">\u53ea\u6709<\/span><\/i><span style=\"font-weight: 400;\">\u5177\u6709\u8be5\u540d\u79f0\u7684\u4ece\u8bbe\u5907\u4f1a\u53d1\u751f\u54cd\u5e94\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I<\/span><span style=\"font-weight: 400;\"><sup><sup>2<\/sup><\/sup><\/span><span style=\"font-weight: 400;\">C\u901a\u4fe1\u7ebf\u8def\u4e2d\u7684\u5730\u5740\u548c\u5bf9\u5e94\u6570\u636e\u770b\u8d77\u6765\u50cf\u4e0b\u56fe\u8fd9\u6837\u3002<\/span><\/p>\n<div id=\"attachment_4972\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4972\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019-300x67.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019-260x58.jpg 260w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019-50x11.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image019-150x33.jpg 150w\" alt=\"arduino communication\" width=\"700\" height=\"156\" aria-describedby=\"caption-attachment-4972\" \/><\/p>\n<p id=\"caption-attachment-4972\" class=\"wp-caption-text\">\u56fe9\uff1a\u901a\u4fe1\u4e2d\u7684\u5730\u5740\u4e0e\u5bf9\u5e94\u6570\u636e\u6837\u56fe\/ \u00a9tessel.io<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u8bf7\u6ce8\u610f\u901a\u4fe1\u7ebf\u4e0a\u7684<\/span><i><span style=\"font-weight: 400;\">ACK<\/span><\/i><span style=\"font-weight: 400;\"> \u548c <\/span><i><span style=\"font-weight: 400;\">NACK<\/span><\/i><span style=\"font-weight: 400;\">\u8bf7\u6ce8\u610f\u901a\u4fe1\u7ebf\u4e0a\u7684ACK\u548cNACK\u4f4d\u3002\u8fd9\u4e9b\u4f4d\u8868\u793a\u88ab\u5bfb\u5740\u7684\u4ece\u8bbe\u5907\u662f\u5426\u54cd\u5e94\u901a\u4fe1\u2014\u8fd9\u662f\u4e00\u79cd\u5b9a\u671f\u68c0\u67e5\u901a\u4fe1\u662f\u5426\u6309\u7167\u9884\u671f\u8fdb\u884c\u7684\u65b9\u6cd5\u3002\u8fd9\u4e9b\u4f4d\u5f53\u7136\u4e0e\u53d1\u9001\u7684\u5730\u5740\u4f4d\u6216\u6570\u636e\u4f4d\u65e0\u5173\uff0c\u4f46\u662f\u5728\u590d\u6742\u7684\u901a\u4fe1\u4f53\u7cfb\u4e2d\uff0c\u4e0e\u5305\u542b\u8bb8\u591a\u5f00\u59cb\u548c\u7ed3\u675f\u4f4d\u5e76\u4f1a\u53d1\u751f\u505c\u987f\u7684\u7c7b\u4f3cUART\u8fd9\u6837\u7684\u534f\u8bae\u76f8\u6bd4\uff0c\u5b83\u4eec\u53ea\u589e\u52a0\u4e86\u975e\u5e38\u5c11\u7684\u989d\u5916\u65f6\u95f4\u800c\u5df2\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C \u4f7f\u4ece\u8bbe\u5907\u53ef\u4ee5\u81ea\u7531\u51b3\u5b9a\u901a\u4fe1\u8bf7\u6c42\u7684\u65b9\u5f0f\u3002\u5411\u4e0d\u540c\u7684\u4ece\u8bbe\u5907\u5199\u5165\u6216\u53d1\u51fa\u8bf7\u6c42\u9700\u8981\u5728SDA\u7ebf\u4ee5\u4e0d\u540c\u7684\u987a\u5e8f\u5199\u5165\u4e0d\u540c\u7684\u5b57\u8282\u3002\u4f8b\u5982\uff0c\u5728\u67d0\u4e9b\u52a0\u901f\u8ba1\u6a21\u5757\u4e2d\uff0c\u5728\u8bfb\u53d6\u8bf7\u6c42\u53d1\u9001\u4e4b\u524d\uff0c\u9700\u8981\u5199\u5165\u6307\u793a\u4e3b\u8bbe\u5907\u6240\u8981\u8bfb\u53d6\u7684\u786c\u4ef6\u5bc4\u5b58\u5668\u7684\u5b57\u8282\u3002\u5bf9\u4e8e\u8fd9\u4e9b\u89c4\u683c\uff0c\u7528\u6237\u9700\u8981\u53c2\u8003\u4ece\u8bbe\u5907\u6570\u636e\u624b\u518c\u4e2d\u7684\u8bbe\u5907\u5730\u5740\u3001\u5bc4\u5b58\u5668\u5730\u5740\u548c\u8bbe\u5907\u8bbe\u7f6e\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728Arduino\u4e0a\uff0cI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u901a\u8fc7<\/span><i><span style=\"font-weight: 400;\">Wire<\/span><\/i><span style=\"font-weight: 400;\"> \u5e93\uff08Wire.h\uff09\u5b9e\u73b0\u5e94\u7528\u3002Arduino\u53ef\u4ee5\u914d\u7f6e\u4e3a\u4e00\u4e2aI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u4e3b\u8bbe\u5907\u6216\u4ece\u8bbe\u5907\u3002\u5728Arduino Uno\u4e0a\u7684\u8fde\u63a5\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><b>SDA: <\/b><span style=\"font-weight: 400;\">\u6a21\u62df\u5f15\u811a 4<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>SCL: <\/b><span style=\"font-weight: 400;\">\u6a21\u62df\u5f15\u811a 5<\/span><\/li>\n<\/ul>\n<div id=\"attachment_4973\" class=\"wp-caption alignnone\" style=\"width: 710px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4973\" src=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021.jpg\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" srcset=\"https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021.jpg 700w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021-300x214.jpg 300w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021-204x146.jpg 204w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021-50x36.jpg 50w, https:\/\/www.deviceplus.com\/wp-content\/uploads\/2016\/12\/image021-105x75.jpg 105w\" alt=\"arduino communication\" width=\"700\" height=\"500\" aria-describedby=\"caption-attachment-4973\" \/><\/p>\n<p id=\"caption-attachment-4973\" class=\"wp-caption-text\">\u56fe9\uff1aI2C\uff08Wire\uff09SDA\u4e3a\u6a21\u62df\u5f15\u811a4\uff08A4\uff09\uff0cSCL\u4e3a\u6a21\u62df\u5f15\u811a5\uff08A5\uff09<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4ee5\u4e0b\u662f\u6709\u5173Arduino I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u521d\u59cb\u5316\u548c\u4f7f\u7528\u7684C++\u7b80\u8981\u53c2\u8003\u3002<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>I<\/b><b><sup>2<\/sup><\/b><b>C (\u7ebf) Method<\/b><\/td>\n<td><b>\u76ee\u7684<\/b><\/td>\n<td><b>\u4ee3\u7801<\/b><\/td>\n<td><b>\u91ca\u4e49<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">begin<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u542f\u52a8\u5e93\uff0c\u5e76\u4ee5\u4e3b\u8bbe\u5907\u6216\u4ece\u8bbe\u5907\u7684\u8eab\u4efd\u52a0\u5165I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C \u603b\u7ebf\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Wire.begin();<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u4ee5\u4e3b\u8bbe\u5907\u7684\u8eab\u4efd\u52a0\u5165I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C \u603b\u7ebf\u3002\u5982\u679c\u5c06\u5730\u5740\u6307\u5b9a\u4e3a\u65b9\u6cd5\u7684\u53c2\u6570\uff0c\u5219Arduino\u5c06\u4ee5\u8be5\u5730\u5740\u4f5c\u4e3a\u4ece\u8bbe\u5907\u52a0\u5165\u603b\u7ebf\u3002<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">beginTransmission<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5bf9\u4e8e\u914d\u7f6e\u4e3aI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C \u4e3b\u8bbe\u5907\u7684Arduino\uff1a\u542f\u52a8\u4e0e\u5177\u6709\u7ed9\u5b9a\u5730\u5740\u7684\u4ece\u8bbe\u5907\u4e4b\u95f4\u7684\u4f20\u8f93\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\"><sup>Wire.beginTransmission(0x68);<\/sup><\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5f00\u59cb\u5bf9\u5177\u6709\u5341\u516d\u8fdb\u5236\u5730\u5740Ox68\u7684\u4ece\u8bbe\u5907\u8fdb\u884c\u4f20\u8f93\u3002<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">write<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u901a\u8fc7I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u603b\u7ebf\u5199\u5165\u5b57\u8282\u6570\u636e\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Wire.write(0x6B);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u901a\u8fc7I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u603b\u7ebf\u5199\u5165\u503cOx68\u7684\u5b57\u8282\u6570\u636e\u3002<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">requestFrom<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5411\u5177\u6709\u7ed9\u5b9a\u5730\u5740\u7684\u4ece\u8bbe\u5907\u8bf7\u6c42\u6307\u5b9a\u503c\u7684\u5b57\u8282\uff1b\u53ef\u4ee5\u9009\u62e9\u91ca\u653eI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7ebf\u6216\u5c06\u5176\u4fdd\u7559\u4ee5\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u901a\u4fe1\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u6240\u8bf7\u6c42\u7684\u5b57\u8282\u88ab\u653e\u5165\u7f13\u51b2\u533a\uff0c\u968f\u540e\u901a\u8fc7<\/span><i><span style=\"font-weight: 400;\">Wire.read()<\/span><\/i><span style=\"font-weight: 400;\">\u8c03\u7528\u8bfb\u53d6\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\"><sup>Wire.requestFrom(0x68, 6, true);<\/sup><\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u5411\u5730\u5740\u4e3aOx68\u7684\u4ece\u8bbe\u5907\u8bf7\u6c426\u4e2a\u5b57\u8282\u3002\u8bf7\u6c42\u5b8c\u6210\u540e\u91ca\u653eI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7ebf\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5982\u679c\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u4e3a<\/span><i><span style=\"font-weight: 400;\">false<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u5219Arduino\u5c06\u4fdd\u7559I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7ebf\u4ee5\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u901a\u4fe1\uff0c\u800c\u4e0d\u5141\u8bb8\u5176\u4ed6\u8bbe\u5907\u901a\u8fc7\u8be5\u7ebf\u8fdb\u884c\u901a\u4fe1\u3002<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">read<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u4ece\u8bbe\u5907\u53d1\u9001\u6570\u636e\u540e\uff0c\u8bfb\u53d6\u653e\u5165\u7f13\u51b2\u533a\u7684\u5b57\u8282\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8be5\u65b9\u6cd5\u5c06\u5728\u8c03\u7528<\/span><i><span style=\"font-weight: 400;\"> Wire.requestFrom<\/span><\/i><span style=\"font-weight: 400;\">\u4e4b\u540e\u8c03\u7528\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Wire.read();<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u4ece\u7f13\u51b2\u533a\u8bfb\u53d6\u4e00\u4e2a\u5b57\u8282\uff08\u5728\u8c03\u7528<\/span><i><span style=\"font-weight: 400;\">requestFrom<\/span><\/i><span style=\"font-weight: 400;\">\u4e4b\u540e\uff09\u3002\u8981\u4ece\u7f13\u51b2\u533a\u8bfb\u53d6\u4e24\u4e2a\u5b57\u8282\uff0c\u5fc5\u987b\u4e24\u6b21\u8c03\u7528\u8be5\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b: <\/span><\/p>\n<p><span style=\"font-weight: 400;\"><sup>Wire.requestFrom(0x68, 2, true);<\/sup><\/span><\/p>\n<p><span style=\"font-weight: 400;\">Wire.read();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Wire.read();<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">endTransmission<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u7ed3\u675f\u5f53\u524d\u4f20\u8f93\uff1b\u53ef\u4ee5\u9009\u62e9\u91ca\u653eI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7ebf\u6216\u5c06\u5176\u4fdd\u7559\u4ee5\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u901a\u4fe1\u3002<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Wire.endTransmission(true);<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u7ed3\u675f\u4f20\u8f93\u5e76\u91ca\u653eI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u7ebf\u3002<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">\u53ea\u9700\u5c06SDA\u548cSCL\u7ebf\u8fde\u63a5\u5230\u603b\u7ebf\u4e0a\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u603b\u7ebf\u8fde\u63a5\u591a\u4e2a\u4e3b\u8bbe\u5907\u3002\u4f46\u662f\uff0c\u4e00\u6b21\u53ea\u80fd\u6709\u4e00\u4e2a\u4e3b\u8bbe\u5907\u4e0e\u4ece\u8bbe\u5907\u901a\u4fe1\uff0c\u56e0\u4e3a\u8ba9\u591a\u4e2a\u8bbe\u5907\u8fdb\u884c\u76f8\u4e92\u901a\u4fe1\u4f1a\u5bfc\u81f4\u603b\u7ebf\u4e89\u7528\u3002\u540c\u6837\uff0c<\/span><i><span style=\"font-weight: 400;\">\u4e0d\u80fd\u540c\u65f6<\/span><\/i><span style=\"font-weight: 400;\">\u8fdb\u884c<\/span><i><span style=\"font-weight: 400;\">\u4e3b\u8bbe\u5907\u5230\u4ece\u8bbe\u5907<\/span><\/i><span style=\"font-weight: 400;\">\u548c<\/span><i><span style=\"font-weight: 400;\">\u4ece\u8bbe\u5907\u5230\u4e3b\u8bbe\u5907<\/span><\/i><span style=\"font-weight: 400;\">\u4e4b\u95f4\u7684\u53cc\u5411\u901a\u4fe1\uff0c\u56e0\u4e3a\u8fd9\u4e5f\u4f1a\u5bfc\u81f4\u603b\u7ebf\u4e89\u7528\u3002\u8fd9\u4f7f\u5f97I<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u53d8\u6210\u4e86<\/span><i><span style=\"font-weight: 400;\">\u534a\u53cc\u5de5<\/span><\/i><span style=\"font-weight: 400;\">\uff0c\u5c31\u50cfUART\u90a3\u6837\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u603b\u4e4b\uff0c\u591a\u4e2a\u4e3b\u8bbe\u5907\u65e0\u6cd5\u901a\u8fc7\u540c\u4e00\u4e2aI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u603b\u7ebf\u5b9e\u73b0\u76f8\u4e92\u901a\u4fe1\u3002\u5728\u5c06\u591a\u4e2a\u4e3b\u8bbe\u5907\u8fde\u63a5\u5230\u4ece\u8bbe\u5907\u7684\u5e94\u7528\u4e2d\uff0c\u4e3b\u8bbe\u5907\u53ef\u4ee5\u901a\u8fc7\u5355\u72ec\u7684\u603b\u7ebf\u6216\u5355\u72ec\u7684\u901a\u4fe1\u534f\u8bae\u5b9e\u73b0\u76f8\u4e92\u4e4b\u95f4\u7684\u901a\u4fe1\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5982\u679c\u60a8\u5b66\u5b8c\u4e86\u672c\u6559\u7a0b\uff0c\u90a3\u4e48\u5e94\u8be5\u5df2\u7ecf\u62e5\u6709\u6240\u6709\u4f7f\u7528UART\u3001SPI\u548cI<\/span><span style=\"font-weight: 400;\"><sup>2<\/sup><\/span><span style=\"font-weight: 400;\">C\u901a\u4fe1\u534f\u8bae\u6240\u9700\u7684\u5de5\u5177\u4e86\uff01\u67e5\u770b\u6211\u4eec\u7684\u4e00\u4e9bArduino\u9879\u76ee\uff0c\u53ef\u4ee5\u83b7\u53d6\u6709\u5173\u4f7f\u7528\u8fd9\u4e9b\u534f\u8bae\u7684\u66f4\u591a\u793a\u4f8b\uff01<\/span><\/p>\n<p><b>\u9644\u5f55<\/b><\/p>\n<p><span style=\"font-weight: 400;\">C\u8bed\u8a00\u4e2d\u7684\u6309\u4f4d\u64cd\u4f5c: <\/span><a href=\"https:\/\/www.cprogramming.com\/tutorial\/bitwise_operators.html\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/www.cprogramming.com\/tutorial\/bitwise_operators.html<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">\u79fb\u4f4d\u5bc4\u5b58\u5668: <\/span><a href=\"https:\/\/learn.sparkfun.com\/tutorials\/shift-registers\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/learn.sparkfun.com\/tutorials\/shift-registers<\/span><\/a><span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/secure.gravatar.com\/avatar\/a88edce9655952f2934b40a19c105af7?s=128&amp;d=mm&amp;r=g\" alt=\"Rahul Iyer\" 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 &nbsp; \u4eca\u5929\uff0c\u6211\u4eec\u5c06\u8ba8\u8bbaarduino\u901a\u4fe1\u534f\u8bae\u7684\u6709\u5173\u5185\u5bb9\u3002\u8bbe\u5907\u5f80\u5f80\u9700\u8981\u76f8\u4e92\u901a\u4fe1\u4ee5\u4e2d\u7ee7\u6240\u5904\u73af\u5883\u76f8\u5173\u4fe1\u606f\uff0c\u663e\u793a\u5176\u72b6\u6001\u53d8\u5316\uff0c\u6216\u8bf7\u6c42\u6267\u884c\u8f85\u52a9\u64cd\u4f5c\u3002\u5728\u8fdb\u884c\u4efb\u4f55\u7535\u5b50 [&hellip;]","protected":false},"author":3,"featured_media":16188,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1130],"tags":[],"class_list":["post-8572","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\/8572","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=8572"}],"version-history":[{"count":24,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/8572\/revisions"}],"predecessor-version":[{"id":16751,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/8572\/revisions\/16751"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/16188"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=8572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=8572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=8572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}