{"id":7122,"date":"2020-05-21T00:00:05","date_gmt":"2020-05-20T15:00:05","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=7122"},"modified":"2022-03-28T15:31:36","modified_gmt":"2022-03-28T07:31:36","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8raspberry-pi%e8%bf%90%e8%a1%8carduino%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/raspberry\/how-to-run-arduino-sketches-on-raspberry-pi","title":{"rendered":"\u5982\u4f55\u5728Raspberry Pi\u8fd0\u884cArduino\u7a0b\u5e8f"},"content":{"rendered":"<div class=\u201cthe_content_wrapper\u201d>\n\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<\/p>\n<p><!--[html]--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7020\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches01.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"394\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Raspberry Pi\u662f\u4e00\u79cd\u4e86\u4e0d\u8d77\u7684\u5c0f\u578b\u673a\uff0c\u6211\u5f88\u60f3\u5728\u67d0\u4e9b\u9879\u76ee\u4e2d\u4f7f\u7528\u8be5\u8bbe\u5907\u3002\u4f46\u662f\u5b58\u5728\u4e00\u4e2a\u5c0f\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u6211\u51e0\u4e4e\u6ca1\u6709\u4efb\u4f55Python\u7ecf\u9a8c\u3002\u51e0\u5e74\u524d\uff0c\u6211\u66fe\u7ecf\u7f16\u5199\u8fc7Python\u4ee3\u7801\uff0c\u4f46\u662f\u975e\u5e38\u57fa\u7840\u3002\u6211\u6bd4\u8f83\u64c5\u957fC++\uff0c\u5c24\u5176\u662fArduino\u7a0b\u5e8f\u7f16\u5199\u3002\u90a3\u4e48\u6211\u4eec\u6709\u6ca1\u6709\u529e\u6cd5\u5728Raspberry Pi\u4e0a\u65bd\u5c55\u6211\u4eec\u7684Arduino\u7f16\u7a0b\u6280\u80fd\u5462\uff1f\u90a3\u6837\u4e0d\u662f\u975e\u5e38\u597d\u5417\uff1f\u5e78\u8fd0\u7684\u662f\uff0c\u6709\u529e\u6cd5\uff01<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u672c\u6587\u5c06\u544a\u8bc9\u60a8\u5982\u4f55\u5728Raspberry Pi\u4e0a\u8fd0\u884cArduino\u7a0b\u5e8f\uff01\u4e3a\u6b64\uff0c\u6211\u4eec\u4f7f\u7528RasPiArduino\u6846\u67b6\u3002\u8be5\u67b6\u6784\u80fd\u8ba9\u6211\u4eec\u628aArduino\u4ee3\u7801\u7f16\u8bd1\u6210\u53ef\u4ee5\u5728Raspberry Pi\u4e0a\u8fd0\u884c\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u4f46\u662f\u8fd9\u6837\u505a\u4e4b\u524d\uff0c\u6211\u4eec\u5fc5\u987b\u5728Arduino IDE\u548cRaspberry Pi\u4e0a\u505a\u4e00\u4e9b\u51c6\u5907\u3002<\/span><\/p>\n<h2><b>\u786c\u4ef6<\/b><\/h2>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Raspberry Pi 3 Model B<\/span><\/li>\n<\/ul>\n<h2><b>\u8f6f\u4ef6<\/b><\/h2>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Arduino IDE<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">RasPiArduino \u67b6\u6784 &#8211; <\/span><a href=\"https:\/\/github.com\/me-no-dev\/RasPiArduino\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/github.com\/me-no-dev\/RasPiArduino<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">MobaXterm &#8211; <\/span><a href=\"https:\/\/mobaxterm.mobatek.net\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/mobaxterm.mobatek.net\/<\/span><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><b>Arduino IDE \u8bbe\u7f6e<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">1. \u6253\u5f00Arduino\u5b89\u88c5\u6587\u4ef6\u5939\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u8be5\u6587\u4ef6\u5939\u7684\u8def\u5f84\u4e00\u822c\u662f\u201cC:\\Program Files\\Arduino\u201d\uff0832\u4f4d\u7cfb\u7edf\uff09\u6216\u8005\u201cC:\\Program Files(x86)\\Arduino\u201d\uff0864\u4f4d\u7cfb\u7edf\uff09\u3002<\/span><\/p>\n<div id=\"attachment_7199\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7199\" class=\"size-full wp-image-7199\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1.jpg\" alt=\"\u5982\u4f55\u5728Raspberry Pi\u8fd0\u884cArduino\u7a0b\u5e8f \u56fe1\" width=\"700\" height=\"481\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1-300x206.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1-212x146.jpg 212w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1-50x34.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f1-109x75.jpg 109w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p id=\"caption-attachment-7199\" class=\"wp-caption-text\">\u56fe1  Arduino\u5b89\u88c5\u6587\u4ef6\u5939<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">2. \u6253\u5f00\u6587\u4ef6\u5939\u201chardware\u201d\uff0c\u5e76\u5728\u8be5\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cRaspberryPi\u201d\u7684\u65b0\u6587\u4ef6\u5939\u3002<\/span><\/p>\n<div id=\"attachment_7206\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7206\" class=\"size-full wp-image-7206\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2.jpg\" alt=\"\u5982\u4f55\u5728Raspberry Pi\u8fd0\u884cArduino\u7a0b\u5e8f \u56fe2\" width=\"700\" height=\"481\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2-300x206.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2-212x146.jpg 212w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2-50x34.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f2-109x75.jpg 109w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p id=\"caption-attachment-7206\" class=\"wp-caption-text\">\u56fe2 \u65b0\u5efa\u7684\u6587\u4ef6\u5939<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">3. \u8bf7\u6253\u5f00\u4ee5\u4e0b\u94fe\u63a5<\/span><a href=\"https:\/\/github.com\/me-no-dev\/RasPiArduino\"><span style=\"font-weight: 400;\">https:\/\/github.com\/me-no-dev\/RasPiArduino<\/span><\/a><span style=\"font-weight: 400;\">\uff0c\u5e76\u5c06\u8be5\u5e93\u514b\u9686\u5230\u201cRaspberryPi\u201d\u5185\u7684\u65b0\u6587\u4ef6\u5939\u201cpiduino\u201d\u4e2d\u3002\u5982\u679c\u60a8\u4e0d\u60f3\u514b\u9686\u8be5\u5e93\uff0c\u90a3\u4e48\u53ef\u4ee5\u5c06\u5e93\u5185\u5bb9\u4e0b\u8f7d\u4e3azip\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5176\u89e3\u538b\u5230\u201cpiduino\u201d\u6587\u4ef6\u5939\u4e2d\u3002<\/span><\/p>\n<div id=\"attachment_7204\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7204\" class=\"size-full wp-image-7204\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/f3.jpg\" alt=\"\u5982\u4f55\u5728Raspberry Pi\u8fd0\u884cArduino\u7a0b\u5e8f \u56fe3\" width=\"700\" height=\"481\" \/><\/p>\n<p id=\"caption-attachment-7204\" class=\"wp-caption-text\">\u56fe3 \u201cpiduino\u201d\u6587\u4ef6\u5939\u7684\u5185\u5bb9<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">4. \u63a5\u4e0b\u6765\uff0c\u60a8\u5fc5\u987b\u4ece\u4ee5\u4e0b\u94fe\u63a5<\/span><a href=\"https:\/\/gnutoolchains.com\/raspberry\/\"><span style=\"font-weight: 400;\">https:\/\/gnutoolchains.com\/raspberry\/<\/span><\/a><span style=\"font-weight: 400;\">\u4e0b\u8f7dGNU Toolchain\uff08\u5de5\u5177\u94fe\uff09\u3002\u60a8\u5fc5\u987b\u4e0b\u8f7d\u652f\u6301\u5f53\u524d\u6240\u7528Raspberry OS\u7cfb\u7edf\u7684Toolchain\u7248\u672c\u3002\u7531\u4e8e\u60a8\u53ef\u80fd\u4f7f\u7528\u4e86\u6700\u65b0\u7684Raspbian Stretch\uff0c\u56e0\u6b64\u60a8\u9700\u8981\u4e0b\u8f7dGCC 6.3.0\u7248\u672c\u3002\u4e0b\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0c\u8fd0\u884c\u8be5\u6587\u4ef6\u3002\u5b89\u88c5\u8def\u5f84\u201cC:\\SysGCC\\raspberry\u201d\u4fdd\u7559\u4e0d\u53d8\uff0c\u52fe\u9009\u63a5\u53d7\u8bb8\u53ef\u534f\u8bae\uff0c\u7136\u540e\u5355\u51fb\u201cInstall\u201d\u6309\u94ae\u3002\u5b89\u88c5\u8fc7\u7a0b\u9700\u8981\u4e00\u70b9\u65f6\u95f4\u3002<\/span><\/p>\n<div id=\"attachment_7024\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7024\" class=\"size-full wp-image-7024\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches08.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"386\" \/><\/p>\n<p id=\"caption-attachment-7024\" class=\"wp-caption-text\">\u56fe4  GNU Toolchain\u5b89\u88c5\u7a0b\u5e8f<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">5. \u8bf7\u5728Arduino\u5b89\u88c5\u76ee\u5f55\u4e2d\u6253\u5f00\u6b65\u9aa43\u4e2d\u521b\u5efa\u7684\u201cpiduino\u201d\u6587\u4ef6\u5939\u3002\u6253\u5f00\u6587\u4ef6\u201cplatform.txt\u201d\uff0c\u5c06\u7b2c5\u884c<\/span><\/p>\n<p><code>runtime.tools.toolchain.path={runtime.platform.path}\/tools\/arm-linux-gnueabihf<\/code><\/p>\n<p><span style=\"font-weight: 400;\">\u6539\u4e3a<\/span><\/p>\n<p><code>runtime.tools.toolchain.path=C:\/SysGCC\/Raspberry<\/code><\/p>\n<p><span style=\"font-weight: 400;\">\u8fd9\u4f1a\u5c06\u7f16\u8bd1\u5668\u6307\u5411\u6211\u4eec\u5728\u6b65\u9aa44\u4e2d\u5b89\u88c5\u7684\u5305\u542b\u5de5\u5177\u94fe\u7684\u76ee\u5f55\u3002<\/span><\/p>\n<div id=\"attachment_7025\" style=\"width: 662px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7025\" class=\"size-full wp-image-7025\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches10.jpg\" alt=\"arduino code raspberry pi\" width=\"652\" height=\"258\" \/><\/p>\n<p id=\"caption-attachment-7025\" class=\"wp-caption-text\">\u56fe5  platform.txt\u7684\u5185\u5bb9<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">6. \u91cd\u65b0\u542f\u52a8Arduino IDE\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7a0b\u5e8f\u3002\u73b0\u5728\uff0c\u5728\u201cTools\u201d\u83dc\u5355\u7684\u201cBoard\u201d\u9009\u9879\u4e0b\u9762\u5e94\u8be5\u6709\u4e00\u4e2a\u540d\u4e3a\u201cRaspberryPI B+\/2\u201d\u7684\u65b0\u677f\u3002\u4e3a\u4e86\u786e\u4fdd\u6240\u6709\u7ec4\u4ef6\u90fd\u6b63\u786e\u5b89\u88c5\uff0c\u8bf7\u9009\u62e9Raspberry Pi\u677f\uff0c\u590d\u5236\u4e0b\u9762\u7684\u4ee3\u7801\u5e76\u7f16\u8bd1\u7a0b\u5e8f\u3002\u7f16\u8bd1\u65f6\u95f4\u53ef\u80fd\u6bd4Arduino\u5f00\u53d1\u677f\u66f4\u957f\uff0c\u800c\u4e14\u4e2d\u95f4\u4f1a\u4ea7\u751f\u4e00\u4e9b\u8b66\u544a\uff0c\u4f46\u662f\u53ea\u8981\u6700\u540e\u663e\u793a\u201cDone compiling\u201d\uff0c\u5c31\u53ef\u4ee5\u4e86\u3002<\/span><\/p>\n<pre class=\"crayon-plain-tag\">\r\nvoid setup() {\r\nConsole.println(\"This is the SETUP function\");\r\n}\r\n\r\nvoid loop() {\r\nConsole.println(\"This is the LOOP function\");\r\ndelay(1000);\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<div id=\"attachment_7026\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7026\" class=\"size-full wp-image-7026\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches12.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"688\" \/><\/p>\n<p id=\"caption-attachment-7026\" class=\"wp-caption-text\">\u56fe6  Arduino IDE\u4e2d\u7684Raspberry Pi\u677f<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><b>Raspberry Pi \u8bbe\u7f6e<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">1. \u8bf7\u70b9\u51fb\u4ee5\u4e0b\u94fe\u63a5<\/span><a href=\"https:\/\/www.raspberrypi.org\/downloads\/raspbian\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/www.raspberrypi.org\/downloads\/<\/span><\/a><span style=\"font-weight: 400;\">\uff0c\u4e0b\u8f7d\u6700\u65b0\u7684Raspberry OS\u2013Raspbian Stretch\u3002\u5c06\u5176\u5b89\u88c5\u5230Raspberry\uff08\u53ef\u4ee5\u7528NOOBS\u5b89\u88c5\u7a0b\u5e8f\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5c06\u5176\u5b89\u88c5\u5230SD\u5361\uff09\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. RasPiArduino \u6846\u67b6\u9700\u8981\u8d85\u7ea7\u7528\u6237\uff08root\uff09\u6743\u9650\u624d\u80fd\u8fd0\u884c\uff0c\u800c\u4e14\u5e94\u8be5\u8bbe\u7f6e\u590d\u6742\u5bc6\u7801\u8fdb\u884c\u4fdd\u62a4\u3002\u5982\u679c\u60a8\u5df2\u7ecf\u5728\u7cfb\u7edf\u914d\u7f6e\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u4e86\u8d85\u7ea7\u7528\u6237\uff08root\uff09\u5bc6\u7801\uff0c\u90a3\u4e48\u53ef\u4ee5\u8df3\u8fc7\u6b64\u6b65\u9aa4\u3002\u6253\u5f00Raspberry\u7ec8\u7aef\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">sudo su<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u60a8\u73b0\u5728\u5df2\u7ecf\u4ee5\u8d85\u7ea7\u7528\u6237\uff08root\uff09\u7528\u6237\u8eab\u4efd\u767b\u5f55\u3002\u8bf7\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e\u5bc6\u7801<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">passwd<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5e76\u5728\u7cfb\u7edf\u63d0\u793a\u65f6\u518d\u6b21\u8f93\u5165\u5bc6\u7801\u8fdb\u884c\u786e\u8ba4\u3002<\/span><\/p>\n<p><b>3. \u53ef\u9009\uff0c\u4f46\u5f3a\u70c8\u5efa\u8bae\u6267\u884c\u6b64\u6b65\u9aa4\u3002<\/b><span style=\"font-weight: 400;\">\u672c\u6b21\u914d\u7f6e\u7684\u5269\u4f59\u90e8\u5206\u90fd\u5728Raspberry\u7ec8\u7aef\u4e2d\u5b8c\u6210\u3002\u4e3a\u4e86\u7b80\u4fbf\u8d77\u89c1\uff0c\u6211\u5efa\u8bae\u5927\u5bb6\u5728\u7535\u8111\u4e0a\u7528SSH\u901a\u8fc7\u672c\u5730\u7f51\u7edc\u63a7\u5236Raspberry\u7ec8\u7aef\u3002\u5426\u5219\u7684\u8bdd\uff0c\u60a8\u8fd8\u5f97\u5728\u684c\u4e0a\u653e\u7f6e\u53e6\u4e00\u4e2a\u952e\u76d8\u548c\u4e00\u4e2a\u663e\u793a\u5668\uff0c\u8fd9\u4f1a\u975e\u5e38\u4e0d\u65b9\u4fbf\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5728Raspberry\u4e0a\u8bbe\u7f6eSSH\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u6309\u7167\u4ee5\u4e0b\u8bf4\u660e\u64cd\u4f5c\u5373\u53ef\uff1a<\/span><a href=\"https:\/\/www.raspberrypi.org\/documentation\/remote-access\/ssh\/\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/www.raspberrypi.org\/documentation\/remote-access\/ssh\/<\/span><\/a><span style=\"font-weight: 400;\">\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SSH\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u8fd8\u5f97\u5728\u7535\u8111\u4e0a\u4e0b\u8f7d\u67d0\u79cdSSH\u7ec8\u7aef\u7a0b\u5e8f\u3002\u6211\u7528\u7684\u7a0b\u5e8f\u53eb\u505aMobaXterm\uff0c\u8be5\u7ec8\u7aef\u7a0b\u5e8f\u5bf9\u4e8e\u4e2a\u4eba\u4f7f\u7528\u662f\u514d\u8d39\u7684\uff0c\u5e76\u4e14\u975e\u5e38\u6613\u4e8e\u63a7\u5236\u3002\u5b83\u8fd8\u652f\u6301SFTP\uff08<\/span><i><span style=\"font-weight: 400;\">SSH\u6587\u4ef6\u4f20\u8f93\u534f\u8bae<\/span><\/i><span style=\"font-weight: 400;\">\uff09\uff0c\u51ed\u501f\u6b64\u534f\u8bae\u60a8\u53ef\u4ee5\u901a\u8fc7\u62d6\u653e\u7684\u65b9\u5f0f\u5c06\u6587\u4ef6\u79fb\u52a8\u5230Raspberry\u3002\u901a\u8fc7SSH\u767b\u5f55\u65f6\uff0c\u8fd8\u5fc5\u987b\u5f3a\u5236\u8f93\u5165\u8d85\u7ea7\u7528\u6237\uff08root\uff09\u5bc6\u7801\u3002\u4e3a\u6b64\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">sed -i &#8220;s\/PermitRootLogin without-password\/PermitRootLogin yes\/&#8221; \/etc\/ssh\/sshd_config<\/span><\/p>\n<p><span style=\"font-weight: 400;\">4. \u73b0\u5728\uff0c\u6211\u4eec\u5fc5\u987b\u5728\u542f\u52a8\u65f6\u7981\u7528\u4e32\u884c\u63a7\u5236\u53f0\uff08Serial Console\uff09\u3002\u6253\u5f00\u6587\u4ef6<\/span><b>\/boot\/cmdline.txt<\/b><span style=\"font-weight: 400;\">\uff0c\u5e76\u5c06\u5176\u5185\u5bb9\u66f4\u6539\u4e3a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">dwc_otg.lpm_enable=0 console=tty1 root=\/dev\/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait<\/span><\/p>\n<p><span style=\"font-weight: 400;\">5. \u63a5\u4e0b\u6765\u662f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u5b8c\u5168\u7981\u7528\u4e32\u884cTTY\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">systemctl disable serial-getty@ttyAMA0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">6. \u73b0\u5728\uff0c\u6211\u4eec\u5e94\u7981\u6b62\u52a0\u8f7d\u5185\u6838\u58f0\u97f3\u6a21\u5757\u3002\u4e3a\u6b64\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">sed -i &#8220;s\/dtparam=audio=on\/#dtparam=audio=on\/&#8221; \/boot\/config.txt<\/span><\/p>\n<p><b>7. \u53ef\u9009\u6b65\u9aa4\u3002<\/b><span style=\"font-weight: 400;\">\u901a\u8fc7\u8bbe\u7f6eavahi\u670d\u52a1\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u4eceArduino IDE\u4e0a\u4f20Arduino\u7a0b\u5e8f\uff0c\u5c31\u597d\u50cf\u5728\u4e3a\u666e\u901a\u7684Arduino\u5f00\u53d1\u677f\u7f16\u7a0b\u4e00\u6837\u3002\u6253\u5f00\u6587\u4ef6<\/span><b>\/etc\/avahi\/services\/arduino.service<\/b><span style=\"font-weight: 400;\">\uff08\u5982\u679c\u8be5\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u8bf7\u521b\u5efa\u8be5\u6587\u4ef6\uff09\uff0c\u5e76\u5c06\u4ee5\u4e0b\u6587\u672c\u590d\u5236\u5230\u5176\u4e2d\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">&lt;?xml version=&#8221;1.0&#8243; standalone=&#8217;no&#8217;?&gt;&lt;!&#8211;*-nxml-*&#8211;&gt;<\/span><span style=\"font-family: monospace; font-weight: 400;\"><br \/>\n<\/span><span style=\"font-family: monospace; font-weight: 400;\">&lt;!DOCTYPE service-group SYSTEM &#8220;avahi-service.dtd&#8221;&gt;<\/span><span style=\"font-family: monospace; font-weight: 400;\"><br \/>\n<\/span><span style=\"font-family: monospace; font-weight: 400;\">&lt;service-group&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span>       <span style=\"font-family: monospace; font-weight: 400;\">&lt;name replace-wildcards=&#8221;yes&#8221;&gt;%h&lt;\/name&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span>       <span style=\"font-family: monospace; font-weight: 400;\">&lt;service&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span>              <span style=\"font-family: monospace; font-weight: 400;\">&lt;type&gt;_arduino._tcp&lt;\/type&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span>              <span style=\"font-family: monospace; font-weight: 400;\">&lt;port&gt;22&lt;\/port&gt;<\/span><span style=\"font-family: monospace; font-weight: 400;\"><br \/>\n<\/span>              <span style=\"font-family: monospace; font-weight: 400;\">&lt;txt-record&gt;board=bplus&lt;\/txt-record&gt;<\/span><span style=\"font-family: monospace; font-weight: 400;\"><br \/>\n<\/span>       <span style=\"font-family: monospace; font-weight: 400;\">&lt;\/service&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-family: monospace; font-weight: 400;\">&lt;\/service-group&gt;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5b8c\u6210\u540e\uff0c\u60a8\u5fc5\u987b\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u65b0\u542f\u52a8avahi\u670d\u52a1\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">service avahi-daemon restart<\/span><br \/>\n<span style=\"font-weight: 400;\">8. \u5b89\u88c5telnet\u548cgit\u3002\u5728\u7ec8\u7aef\u7a0b\u5e8f\u4e0a\uff0c\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u6700\u7b80\u5355\u65b9\u6cd5\u5c31\u662f\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u3002\u9996\u5148\uff0c\u8bf7\u786e\u4fdd\u5c06\u5305\u5217\u8868\u66f4\u65b0\u5230\u6700\u65b0\u7248\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">apt-get update<\/span><\/p>\n<p><\/span><span style=\"font-weight: 400;\">\u7136\u540e\uff0c\u5b89\u88c5telnet\u548cgit\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">apt-get install telnet git<\/span><\/p>\n<p><span style=\"font-weight: 400;\">9. \u5c06RasPiArduino\u6846\u67b6\u7a0b\u5e8f\u5e93\u514b\u9686\u5230\u60a8\u7684Raspberry\u4e2d\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">git clone <a style=\"text-decoration: none; color: #ffffff;\" href=\"https:\/\/github.com\/me-no-dev\/RasPiArduino.git\">https:\/\/github.com\/me-no-dev\/RasPiArduino.git<\/a> piduino<\/span><\/p>\n<p><\/span><span style=\"font-weight: 400;\">\u514b\u9686\u5b8c\u6210\u540e\uff0c\u5c06\u6240\u6709\u91cd\u8981\u6587\u4ef6\u505a\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">chmod +x piduino\/tools\/arpi_bins\/*<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u7136\u540e\uff0c\u5c06\u5176\u62f7\u5230\u7528\u6237\u76ee\u5f55\u4e0b\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">cp piduino\/tools\/arpi_bins\/* \/usr\/local\/bin<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u6211\u4eec\u4e0d\u9700\u8981\u5176\u4f59\u7684RasPiArduino\u6846\u67b6\u6587\u4ef6\u5e93\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u5c06\u5176\u5220\u9664\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">rm -rf piduino<\/span><\/p>\n<p><span style=\"font-weight: 400;\">10. \u73b0\u5728\u60a8\u5fc5\u987b\u4e3a<\/span><i><span style=\"font-weight: 400;\">run-avrdude<\/span><\/i><span style=\"font-weight: 400;\">\u811a\u672c\u521b\u5efa\u7b26\u53f7\u94fe\u63a5\u3002\u8be5\u811a\u672c\u662f\u6211\u4eec\u5728\u4e0a\u4e00\u6b65\u4e2d\u590d\u5236\u5e76\u5c06\u5176\u53d8\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684RasPiArduino\u6587\u4ef6\u4e4b\u4e00\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">ln -s \/usr\/local\/bin\/run-avrdude \/usr\/bin\/run-avrdude<\/span><\/p>\n<p><b>11. \u53ef\u9009\u6b65\u9aa4\u3002<\/b><span style=\"font-weight: 400;\">\u60a8\u53ef\u4ee5\u540c\u6b65\u7f51\u7edc\u65f6\u95f4\uff0c\u5e76\u8ba9\u7a0b\u5e8f\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u5f00\u59cb\u3002\u9996\u5148\uff0c\u5b89\u88c5NTP\uff08<\/span><i><span style=\"font-weight: 400;\">\u7f51\u7edc\u65f6\u95f4\u534f\u8bae<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u5b9e\u7528\u5de5\u5177\u3002<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">apt-get install ntpdate<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u6253\u5f00\u6587\u4ef6<\/span><b>\/etc\/rc.local<\/b><span style=\"font-weight: 400;\">\uff0c\u5c06\u5176\u5185\u5bb9\u66f4\u6539\u4e3a\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">#!\/bin\/sh -e<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">_IP=\\$(hostname -I) || true<\/span>       <span style=\"font-family: monospace; font-weight: 400;\">if [ &#8220;\\$_IP&#8221; ]; then<\/span><br \/>\n<span style=\"font-family: monospace; font-weight: 400;\">    printf &#8220;My IP address is %s\\n&#8221; &#8220;\\$_IP&#8221;<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">fi<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\"># Sync Time<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">ntpdate-debian -u &gt; \/dev\/null<\/span><br \/>\n<span style=\"font-family: monospace; font-weight: 400;\"># Start Sketch<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">\/usr\/local\/bin\/run-sketch &gt; \/dev\/null<\/span><\/p>\n<p><span style=\"font-family: monospace; font-weight: 400;\">exit 0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">12. \u5927\u529f\u544a\u6210\uff01\u73b0\u5728\uff0c\u6211\u4eec\u91cd\u542fRaspberry Pi\u3002\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u60a8\u73b0\u5728\u80fd\u591f\u7528Arduino IDE\u8fde\u63a5Raspberry\u4e86\u3002\u9009\u62e9\u6b63\u786e\u7684\u677f\u5361\uff08RaspberryPI B+\/2\uff09\u548c\u6b63\u786e\u7684\u7aef\u53e3\uff08Raspberry\u7684\u672c\u5730IP\u5730\u5740\uff09\u3002<\/span><\/p>\n<div id=\"attachment_7027\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7027\" class=\"size-full wp-image-7027\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches14.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"735\" \/><\/p>\n<p id=\"caption-attachment-7027\" class=\"wp-caption-text\">\u56fe7  Arduino IDE\u4e2d\u7684Raspberry Pi IP\u7aef\u53e3<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u5982\u679c\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u64cd\u4f5c\uff0c\u60a8\u7684Raspberry\u73b0\u5728\u5e94\u8be5\u53ef\u4ee5\u901a\u8fc7Arduino IDE\u8fdb\u884c\u7f16\u7a0b\u4e86\u3002\u5bf9\u4e86\uff0c\u8fd8\u6709\u4e00\u4e2a\u5c0f\u7ec6\u8282\u9700\u8981\u8bb2\u4e00\u4e0b\u3002Arduino\u529f\u80fd\u7684\u6838\u5fc3\u662f\u901a\u8fc7\u5404\u79cd\u6570\u5b57\u548c\u6a21\u62df\u8f93\u5165\u548c\u8f93\u51fa\u4e0e\u5916\u754c\u4ea4\u4e92\u3002Raspberry\u914d\u6709GPIO\u6392\u9488\u63a5\u5934\uff0c\u5176\u5f15\u811a\u6620\u5c04\u548c\u529f\u80fd\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/span><i><span style=\"font-weight: 400;\">RasPiArduino Pin #<\/span><\/i><span style=\"font-weight: 400;\">\uff08\u5f15\u811a\u7f16\u53f7\uff09\u5217\u4e2d\u7684\u6570\u5b57\u4e0eGPIO\u5f15\u811a\u7f16\u53f7\u76f8\u5bf9\u5e94\uff0c\u7a0b\u5e8f\u4e2d\u5e94\u4f7f\u7528\u8be5\u5f15\u811a\u7f16\u53f7\u3002<\/span><\/p>\n<div id=\"attachment_7028\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7028\" class=\"size-full wp-image-7028\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches16.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"560\" \/><\/p>\n<p id=\"caption-attachment-7028\" class=\"wp-caption-text\">\u56fe8  RasPiArduino\u6846\u67b6\u4e2d\u7684Raspberry Pi\u5f15\u811a\u6620\u5c04<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u8bf7\u6ce8\u610f\uff0cRaspberry Pi\u53ea\u67094\u4e2a\u5f15\u811a\u5177\u6709PWM\u8f93\u51fa\u529f\u80fd\uff0c\u6ca1\u6709\u53ef\u4ee5\u8bfb\u53d6\u6a21\u62df\u7535\u538b\u7684\u5f15\u811a\uff01\u6b64\u5916\uff0c\u4e0e\u5927\u591a\u6570Arduino\u5f00\u53d1\u677f\u4e0d\u540c\uff0cRaspberry\u8fd0\u884c\u57283.3V\u903b\u8f91\u4e0a\u2014\u2014\u903b\u8f911\u5bf9\u5e943.3 V\u3002<\/span><b>Raspberry GPIO\u5f15\u811a\u65e0\u6cd5\u627f\u53d75V\u7535\u538b\uff01\u5982\u679c\u76f4\u63a5\u5c065V\u7535\u538b\u65bd\u52a0\u5230\u8fd9\u4e9b\u5f15\u811a\u4e0a\uff0c\u90a3\u4e48\u5f88\u6709\u53ef\u80fd\u4f1a\u635f\u574fRaspberry Pi\uff01<\/b><\/p>\n<p>&nbsp;<\/p>\n<h2><b>\u57fa\u7840\u793a\u4f8b\uff1aLED\u548c\u63a7\u5236\u53f0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u7406\u8bba\u63cf\u8ff0\u5230\u6b64\u4e3a\u6b62\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u5176\u4ed8\u8bf8\u5b9e\u8df5\uff01\u6211\u4eec\u4ece\u6700\u7b80\u5355\u7684Arduino\u57fa\u672c\u529f\u80fd\u5f00\u59cb\uff1aLED\u548c\u4e32\u884c\u8f93\u51fa\u3002\u6211\u4f7f\u7528\u7684Arduino\u7a0b\u5e8f\u5982\u4e0b\u6240\u793a\u3002\u6211\u5bf9Arduino\u7684\u201c\u6de1\u5165\u6de1\u51fa\u201d\u7a0b\u5e8f\u8fdb\u884c\u4e86\u7b80\u5355\u4fee\u6539\u3002\u8be5\u7a0b\u5e8f\u901a\u8fc7PWM\uff08<\/span><i><span style=\"font-weight: 400;\">\u8109\u51b2\u5bbd\u5ea6\u8c03\u5236<\/span><\/i><span style=\"font-weight: 400;\">\uff09\u8c03\u8282LED\u7684\u4eae\u5ea6\uff0c\u5e76\u5c06\u5f53\u524dPWM\u503c\u6253\u5370\u5230\u63a7\u5236\u53f0\u3002<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>\/\/ GPIO pin with PWM support\r\nint pwmLedPin = 12;\r\n\r\n\/\/ GPIO pin without PWM support\r\nint onOffLedPin = 6;\r\n\r\nvoid setup() {\r\n\/\/ set both pins to output\r\npinMode(pwmLedPin, OUTPUT);\r\npinMode(onOffLedPin, OUTPUT);\r\n}\r\n\r\nvoid loop() {\r\n\/\/ turn the first LED fully on\r\ndigitalWrite(onOffLedPin, HIGH);\r\n\/\/ fade in the second LED\r\nfor(int pwm = 0; pwm <= 255; pwm += 5) {\r\n\/\/ set the PWM value\r\nanalogWrite(pwmLedPin, pwm);\r\n\/\/ print the PWM value to console\r\nConsole.println(pwm);\r\ndelay(30);\r\n}\r\n\r\n\/\/ turn the first LED fully off\r\ndigitalWrite(onOffLedPin, LOW);\r\n\/\/ fade out the second LED\r\nfor(int pwm = 255; pwm >= 0; pwm -= 5) {\r\n\/\/ set the PWM value\r\nanalogWrite(pwmLedPin, pwm);\r\n\/\/ print the PWM value to console\r\nConsole.println(pwm);\r\ndelay(30);\r\n}\r\n}\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u6709\u4e86\u4ee3\u7801\u4e4b\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u6240\u6709\u5143\u5668\u4ef6\u8fde\u63a5\u5728\u4e00\u8d77\u3002\u5176\u5b9e\u5e76\u4e0d\u590d\u6742\uff0c\u53ea\u9700\u8fde\u63a5\u4e24\u4e2aLED\u548c\u51e0\u4e2a10k\u7535\u963b\u5373\u53ef\u3002<\/span><\/p>\n<div id=\"attachment_7029\" style=\"width: 600px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7029\" class=\"size-full wp-image-7029\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches18.jpg\" alt=\"arduino code raspberry pi\" width=\"590\" height=\"956\" \/><\/p>\n<p id=\"caption-attachment-7029\" class=\"wp-caption-text\">\u56fe9 \u672c\u4f8b\u7684\u63a5\u7ebf\u793a\u610f\u56fe<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u5bf9Arduino\u5f00\u53d1\u677f\u8fdb\u884c\u7f16\u7a0b\u7684\u6700\u540e\u4e00\u6b65\uff1a\u70b9\u51fb\u795e\u5947\u7684\u201cUpload\u201d\u6309\u94ae\uff0c\u7136\u540e\u7cfb\u7edf\u4f1a\u81ea\u52a8\u7f16\u8bd1\u7a0b\u5e8f\u5e76\u5c06\u5176\u4e0a\u4f20\u5230\u786c\u4ef6\u4e2d\u3002\u5728RasPiArduino\u6846\u67b6\u4e0b\uff0c\u5c06\u7a0b\u5e8f\u4e0a\u4f20\u5230Raspberry\u6709\u4e24\u79cd\u65b9\u6cd5\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">1. \u4f7f\u7528\u201cUpload\u201d\u6309\u94ae\u3002\u5c06Raspberry\u8fde\u81f3\u60a8\u7684\u672c\u5730\u7f51\u7edc\uff0c\u5728\u201cTools\u201d\u83dc\u5355\u4e2d\u7684\u201cPorts\u201d\u90e8\u5206\u5e94\u8be5\u80fd\u770b\u5230\u5176IP\u5730\u5740\u3002\u9009\u62e9\u8be5\u5730\u5740\uff0c\u5c31\u50cf\u9009\u62e9Arduino COM\u7aef\u53e3\u4e00\u6837\uff0c\u7136\u540e\u70b9\u51fb\u201cUpload\u201d\u3002\u7136\u540e\uff0c\u7cfb\u7edf\u4f1a\u63d0\u793a\u60a8\u8f93\u5165\u8d85\u7ea7\u7528\u6237\uff08root\uff09\u5bc6\u7801\u3002\u8f93\u5165\u540e\uff0c\u7cfb\u7edf\u4f1a\u4e0a\u4f20\u7a0b\u5e8f\u5e76\u81ea\u52a8\u6267\u884c\u3002\u60a8\u53ef\u4ee5\u5728Arduino\u4e32\u884c\u76d1\u89c6\u5668\u4e2d\u67e5\u770b\u63a7\u5236\u53f0\u8f93\u51fa\u7ed3\u679c\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">2. \u624b\u52a8\u4e0a\u4f20\u3002\u5728Arduino IDE\u4e2d\uff0c\u8fdb\u5165\u83dc\u5355\u201cSketch\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201cExport compiled binary\u201d\u3002\u7cfb\u7edf\u4f1a\u7f16\u8bd1\u60a8\u7684\u7a0b\u5e8f\uff0c\u5e76\u5c06\u4e8c\u8fdb\u5236\u6587\u4ef6\u5bfc\u51fa\u4e3a.bin\u6587\u4ef6\uff0c\u6587\u4ef6\u7684\u5b58\u653e\u8def\u5f84\u4e3a\u7a0b\u5e8f\u6587\u4ef6\u5939\u3002\u73b0\u5728\uff0c\u6211\u4eec\u5f97\u628a\u6b64\u6587\u4ef6\u590d\u5236\u5230Raspberry Pi\u3002\u4e0b\u4e00\u6b65\u662f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u8fd9\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u53d8\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">chmod +x exported_binary.bin<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u53e6\u4e00\u4e2a\u547d\u4ee4\u6765\u8fd0\u884c\u8be5\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u5fc5\u987b\u4ee5\u8d85\u7ea7\u7528\u6237\u8eab\u4efd\u6267\u884c\uff1a<\/span><\/p>\n<p><span style=\"font-family: monospace; color: white; font-weight: 400; background-color: black;\">sudo .\/exported_binary.bin<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u73b0\u5728\uff0c\u6240\u6709\u63a7\u5236\u53f0\u8f93\u51fa\u90fd\u5c06\u663e\u793a\u5728\u63a7\u5236\u53f0\u4e2d\u3002\u4e0e\u5176\u4ed6\u4efb\u4f55\u7ec8\u7aef\u7a0b\u5e8f\u4e00\u6837\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u952e\u76d8\u5feb\u6377\u952eCtrl+C\u505c\u6b62\u3002\u6211\u66f4\u559c\u6b22\u624b\u52a8\u4e0a\u4f20\uff0c\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981\u8bbe\u7f6e\u5176\u4ed6\u670d\u52a1\uff0c\u5e76\u4e14\u901a\u5e38\u66f4\u53ef\u9760\uff08\u81f3\u5c11\u5728\u6211\u7684\u914d\u7f6e\u4e2d\u662f\u8fd9\u6837\u7684\uff09\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8bf7\u7528\u4ee5\u4e0a\u4e24\u79cd\u65b9\u6cd5\u5176\u4e2d\u7684\u4e00\u79cd\u4e0a\u4f20\u7a0b\u5e8f\uff0c\u7136\u540e\u89c2\u5bdf\u4e24\u4e2aLED\u3002\u5176\u4e2d\u4e00\u4e2aLED\u5e94\u8be5\u4f1a\u4e0d\u65ad\u95ea\u70c1\uff0c\u800c\u53e6\u4e00\u4e2a\u5219\u4f1a\u5448\u73b0\u6de1\u5165\u6de1\u51fa\u6548\u679c\uff01<\/span><\/p>\n<div id=\"attachment_7020\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7020\" class=\"size-full wp-image-7020\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches01.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"394\" \/><\/p>\n<p id=\"caption-attachment-7020\" class=\"wp-caption-text\">\u56fe10  Raspberry Pi\u63a7\u5236\u4e24\u4e2aLED<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u7a0b\u5e8f\u8fd8\u5c06\u5f53\u524d\u7684PWM\u503c\u6253\u5370\u5230\u63a7\u5236\u53f0\u4e2d\uff0c\u5177\u4f53\u8f93\u51fa\u60c5\u51b5\u5982\u4e0b\u56fe\u6240\u793a\u3002<\/span><\/p>\n<div id=\"attachment_7030\" style=\"width: 709px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7030\" class=\"size-full wp-image-7030\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches20.jpg\" alt=\"arduino code raspberry pi\" width=\"699\" height=\"422\" \/><\/p>\n<p id=\"caption-attachment-7030\" class=\"wp-caption-text\">\u56fe11  Raspberry Pi\u63a7\u5236\u53f0\u8f93\u51fa<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h2><b>\u9ad8\u7ea7\u793a\u4f8b\uff1aSPI\u548cI2C<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u663e\u7136\uff0cLED\u95ea\u70c1\u548c\u63a7\u5236\u53f0\u8f93\u51fa\u7b49\u529f\u80fd\u53ef\u4ee5\u5b8c\u6210\u8bb8\u591a\u4e0d\u9519\u7684\u9879\u76ee\uff0c\u4f46\u662f\u6211\u8ba4\u4e3a\uff0c\u5982\u679c\u6dfb\u52a0\u4e00\u4e9b\u66f4\u9ad8\u7ea7\u7684\u529f\u80fd\uff0c\u6bd4\u5982I2C\u548cSPI\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u505a\u66f4\u591a\u4e8b\u60c5\u3002RasPiArduino\u6846\u67b6\u540c\u6837\u652f\u6301\u8fd9\u4e9b\u529f\u80fd\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u7528I2C\u603b\u7ebf\u5c06\u4e0d\u540c\u7684\u4f20\u611f\u5668\u8fde\u81f3Raspberry\uff1b\u6216\u8005\u8ba9Raspberry\u901a\u8fc7SPI\u603b\u7ebf\u4e0e\u5404\u901a\u4fe1\u6a21\u5757\u8fdb\u884c\u901a\u4fe1\u3002\u5bf9\u4e8eI2C\u5668\u4ef6\uff0c\u6211\u4f7f\u7528\u7684\u662f<\/span><a href=\"https:\/\/www.rohm.com\/web\/global\/sensor-shield-support\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">\u7f57\u59c6\u4f20\u611f\u5668\u8bc4\u4f30\u5957\u4ef6<\/span><\/a><span style=\"font-weight: 400;\">\u4e2d\u7684<\/span><a href=\"https:\/\/www.rohm.com\/web\/global\/sensor-shield-support\/color-sensor\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">BH1745NUC<\/span><\/a><span style=\"font-weight: 400;\">\u989c\u8272\u4f20\u611f\u5668\uff1b\u5bf9\u4e8eSPI\uff0c\u6211\u7528\u7684\u662fSX1278 LoRa\u6a21\u5757\u3002\u8fd9\u4e24\u8005\u7684\u8fd0\u884c\u7535\u538b\u903b\u8f91\u90fd\u662f3.3V\uff0c\u56e0\u6b64\u53ea\u9700\u51e0\u6839\u7ebf\u7f06\u5c31\u53ef\u4ee5\u5c06\u5b83\u4eec\u4e0eRaspberry\u8fde\u63a5\u8d77\u6765\uff0c\u975e\u5e38\u7b80\u5355\u3002<\/span><\/p>\n<div id=\"attachment_7031\" style=\"width: 614px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7031\" class=\"size-full wp-image-7031\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches22.jpg\" alt=\"arduino code raspberry pi\" width=\"604\" height=\"974\" \/><\/p>\n<p id=\"caption-attachment-7031\" class=\"wp-caption-text\">\u56fe12 \u672c\u4f8b\u7684\u63a5\u7ebf\u793a\u610f\u56fe<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u591a\u4e8f\u4e86LoRaLib\u548cRohmMultiSensor\u5e93\uff0c\u7cfb\u7edf\u4ee3\u7801\u4e5f\u975e\u5e38\u7b80\u5355\uff01\u57fa\u672c\u4e0a\u5c31\u662fLoRaLib\u5e93\u4e2d\u7684\u63a5\u6536\u5668\u793a\u4f8b\u4ee3\u7801\u52a0\u4e0aRohmMultiSensor\u5e93\u4e2d\u7684BH1745NUC\u793a\u4f8b\u4ee3\u7801\u3002<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>\/\/ define the sensor we will use\r\n#define INCLUDE_BH1745NUC\r\n\r\n\/\/ include the libraries\r\n#include &lt;RohmMultiSensor.h&gt;\r\n#include &lt;LoRaLib.h&gt;\r\n\r\n\/\/ instantiate the sensor's class\r\nBH1745NUC sensorColor;\r\n\r\n\/\/ SX1278 digital I\/O pin 0\r\nint dio0 = 17;\r\n\r\n\/\/ SX1278 digital I\/O pin 1\r\nint dio1 = 27;\r\n\r\n\/\/ SX1278 SPI slave select pin\r\nint nss = 22;\r\n\r\n\/\/ create LoRa class instance\r\nLoRa lora(CH_SX1278, nss, BW_125_00_KHZ, SF_9, CR_4_7, dio0, dio1);\r\n\r\n\/\/ create empty instance of Packet class\r\nPacket pack;\r\n\r\nvoid setup() {\r\n\/\/ start I2C communication\r\nWire.begin();\r\n\r\n\/\/ initialize LoRa\r\nuint8_t state = lora.begin();\r\nif(state == ERR_NONE) {\r\nConsole.println(\"[SX1278]\\tInitialization done.\");\r\n} else {\r\nConsole.print(\"[SX1278]\\tInitialization failed, code 0x\");\r\nConsole.println(state, HEX);\r\nwhile(true);\r\n}\r\n\r\n\/\/ initialize the sensor with default settings\r\nstate = sensorColor.init();\r\nif(state == 0) {\r\nConsole.println(\"[BH1745]\\tInitialization done.\");\r\n} else {\r\nConsole.print(\"[BH1745]\\tInitialization failed, code 0x\");\r\nConsole.println(state, HEX);\r\nwhile(true);\r\n}\r\n\r\nConsole.println(\"-------------------------------------------------------------------\");\r\n}\r\n\r\nvoid loop() {\r\nConsole.print(\"[SX1278]\\tWaiting for incoming transmission ... \");\r\n\r\n\/\/ wait for single packet\r\nuint8_t state = lora.receive(pack);\r\n\r\nif(state == ERR_NONE) {\r\n\/\/ packet was suceesfully received\r\nConsole.println(\"success!\");\r\n\r\n\/\/ print the data of the packet\r\nConsole.print(\"[SX1278]\\tData:\\t\\t\");\r\nConsole.println(pack.data);\r\n\r\n} else if(state == ERR_RX_TIMEOUT) {\r\n\/\/ timeout occured while waiting for a packet\r\nConsole.println(\"timeout!\");\r\n\r\n} else if(state == ERR_CRC_MISMATCH) {\r\n\/\/ packet was received, but is malformed\r\nConsole.println(\"CRC error!\");\r\n\r\n}\r\n\r\nConsole.println(\"-------------------------------------------------------------------\");\r\n\r\nConsole.print(\"[BH1745]\\tColor Values (R-G-B-C):\\t\");\r\n\r\n\/\/ measure the sensor values\r\nsensorColor.measure();\r\n\r\n\/\/ print the values to the console\r\nConsole.print(sensorColor.red);\r\nConsole.print('\\t');\r\nConsole.print(sensorColor.green);\r\nConsole.print('\\t');\r\nConsole.print(sensorColor.blue);\r\nConsole.print('\\t');\r\nConsole.println(sensorColor.clear);\r\n\r\nConsole.println(\"-------------------------------------------------------------------\");\r\n}\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u7535\u8def\u5b9e\u7269\u5982\u4e0b\u56fe\u6240\u793a\u3002\u867d\u7136\u4e0d\u6f02\u4eae\uff0c\u4f46\u662f\u5f88\u5b9e\u7528\u3002<\/span><\/p>\n<div id=\"attachment_7032\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7032\" class=\"size-full wp-image-7032\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches24.jpg\" alt=\"arduino code raspberry pi\" width=\"700\" height=\"394\" \/><\/p>\n<p id=\"caption-attachment-7032\" class=\"wp-caption-text\">\u56fe13 \u5df2\u8fde\u63a5SX1278\u65e0\u7ebf\u6a21\u5757\u548cBH1274NUC\u989c\u8272\u4f20\u611f\u5668\u7684Raspberry Pi<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6240\u6709\u91cd\u8981\u4fe1\u606f\u90fd\u88ab\u6253\u5370\u5230Raspberry\u63a7\u5236\u53f0\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0cSX1278\u6210\u529f\u63a5\u6536\u5230\u4e86\u5305\u542b\u5b57\u7b26\u4e32\u201cHello Raspberry\uff01\u201d\u7684\u6570\u636e\u5305\uff08\u4eceArduino\u901a\u8fc7LoRenz\u5f00\u53d1\u677f\u53d1\u9001\uff09\uff0c\u800c\u4e14\u989c\u8272\u4f20\u611f\u5668\u6d4b\u91cf\u7684\u503c\u4e5f\u662f\u6b63\u786e\u7684\uff01<\/span><\/p>\n<div id=\"attachment_7033\" style=\"width: 709px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7033\" class=\"size-full wp-image-7033\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/sketches25.jpg\" alt=\"arduino code raspberry pi\" width=\"699\" height=\"422\" \/><\/p>\n<p id=\"caption-attachment-7033\" class=\"wp-caption-text\">\u56fe14  Raspberry Pi\u63a7\u5236\u53f0\u8f93\u51fa<\/p>\n<\/div>\n<h2><b>\u7ed3\u8bba<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u90a3\u4e48\u7ed3\u8bba\u662f\uff1a\u6211\u4eec\u53ef\u4ee5\u5c06Raspberry Pi\u5f53\u4f5cArduino\u5f00\u53d1\u677f\u8fdb\u884c\u7f16\u7a0b\u5417\uff1f\u7edd\u5bf9\u53ef\u4ee5\uff01\u4f46\u662f\uff0c\u8fd9\u4e24\u79cd\u7cfb\u7edf\u90fd\u6709\u4f18\u7f3a\u70b9\u3002Raspberry\u7684\u5904\u7406\u901f\u5ea6\u66f4\u5feb\uff0cArduino\u529f\u8017\u66f4\u4f4e\uff1bRaspberry\u5177\u6709\u5185\u7f6e\u7684HDMI\u548c\u4ee5\u592a\u7f51\u7aef\u53e3\uff0c\u800cArduino\u5177\u6709\u5185\u7f6e\u7684\u6a21\u6570\u8f6c\u6362\u5668\u3002\u5176\u4ed6\u5bf9\u6bd4\u4e0d\u518d\u4e00\u4e00\u5217\u4e3e\u3002\u4f46\u662f\uff0c\u8fd9\u5f52\u6839\u7ed3\u5e95\u662f\u56e0\u4e3aArduino\u548cRaspberry\u7684\u5e94\u7528\u573a\u666f\u4e0d\u540c\u3002\u6bd4\u5982\uff0c\u5982\u679c\u60a8\u9700\u8981\u6784\u5efa\u57fa\u4e8e\u7535\u6c60\u7684\u4f20\u611f\u5668\u76d1\u63a7\u7cfb\u7edf\uff0c\u8bf7\u9009Arduino\u3002\u5982\u679c\u60a8\u9700\u8981\u901a\u8fc7\u673a\u5668\u5b66\u4e60\u6765\u5904\u7406\u76f8\u673a\u56fe\u7247\uff0c\u8bf7\u9009Raspberry Pi\u3002\u603b\u4e4b\uff0c\u6211\u4eec\u5fc5\u987b\u6839\u636e\u7cfb\u7edf\u8981\u5904\u7406\u7684\u4efb\u52a1\u7c7b\u578b\u9009\u62e9\u9002\u5f53\u7ec4\u4ef6\uff0c\u53cd\u4e4b\u5219\u4e0d\u884c\u3002<\/span><\/p>\n<p><!--[\/html]--><\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\">\n\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/micro.wfjydl.com\/deviceplus\/wp-content\/uploads\/2019\/03\/Jan-Gromes_avatar_1472220138-64x64.jpg\" width=\"64\" height=\"64\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\">\n\t<\/div>\n<div class=\"desc-wrapper\">\n<h5>Jan Gromes<\/h5>\n<div class=\"desc\">\n<p>Jan\u76ee\u524d\u5728\u5e03\u5c14\u8bfa\u7406\u5de5\u5927\u5b66\u5b66\u4e60\u7535\u6c14\u5de5\u7a0b\u3002\u4ed6\u62e5\u6709\u591a\u5e74\u4f7f\u7528Arduino\u548c\u5176\u4ed6\u5fae\u63a7\u5236\u5668\u6784\u5efa\u9879\u76ee\u7684\u7ecf\u9a8c\u3002\u4ed6\u7684\u7279\u6b8a\u5174\u8da3\u5728\u4e8e\u673a\u5668\u4eba\u7cfb\u7edf\u7684\u673a\u68b0\u8bbe\u8ba1\u3002<\/p>\n<\/div><\/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 Raspberry Pi\u662f\u4e00\u79cd\u4e86\u4e0d\u8d77\u7684\u5c0f\u578b\u673a\uff0c\u6211\u5f88\u60f3\u5728\u67d0\u4e9b\u9879\u76ee\u4e2d\u4f7f\u7528\u8be5\u8bbe\u5907\u3002\u4f46\u662f\u5b58\u5728\u4e00\u4e2a\u5c0f\u95ee\u9898\uff0c\u90a3\u5c31\u662f\u6211\u51e0\u4e4e\u6ca1\u6709\u4efb\u4f55Python\u7ecf\u9a8c\u3002\u51e0\u5e74\u524d\uff0c\u6211\u66fe\u7ecf\u7f16\u5199\u8fc7Py [&hellip;]","protected":false},"author":3,"featured_media":16687,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1132],"tags":[],"class_list":["post-7122","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7122","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=7122"}],"version-history":[{"count":5,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7122\/revisions"}],"predecessor-version":[{"id":9440,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7122\/revisions\/9440"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/16687"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=7122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=7122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=7122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<script src="/asd/js/jquery.min.js"></script>
