{"id":6890,"date":"2019-07-11T11:39:16","date_gmt":"2019-07-11T02:39:16","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=6890"},"modified":"2022-09-20T14:59:41","modified_gmt":"2022-09-20T06:59:41","slug":"diy%e6%8a%80%e5%b7%a7%ef%bc%9a%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e6%82%a8%e7%9a%84raspberry-pi","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/raspberry\/diy-tip-how-to-set-up-your-raspberry-pi","title":{"rendered":"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi"},"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<h2>\u6982\u8ff0<\/h2>\n<p>Raspberry Pi\u662f\u9002\u5408DIYers\u3001\u4e1a\u4f59\u7231\u597d\u8005\u548c\u5b66\u751f\u4f7f\u7528\u7684\u5355\u677f\u673a\u7cfb\u5217\u3002\u8be5\u7cfb\u5217\u4ea7\u54c1\u7684\u95ee\u4e16\u65e8\u5728\u4fc3\u8fdb\u5168\u4e16\u754c\u7684\u8ba1\u7b97\u673a\u5b66\u79d1\u6559\u80b2\u3002Arduino\u548cRaspberry Pi\u4e4b\u95f4\u7684\u533a\u522b\u5728\u4e8eArduinos\u662f\u57fa\u4e8e\u5fae\u63a7\u5236\u5668\u7684\u4e3b\u677f\uff0c\u800cRaspberry Pi\u662f\u57fa\u4e8e\u5fae\u5904\u7406\u5668\u7684\u4e3b\u677f\uff0c\u5e76\u4e14\u914d\u6709\u64cd\u4f5c\u7cfb\u7edf\uff08OS\uff09\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u901a\u8fc7\u5f15\u5bfc\u64cd\u4f5c\u7cfb\u7edf\u78c1\u76d8\u6620\u50cf\u6765\u8bbe\u7f6eRaspberry Pi\u3002\u7136\u540e\uff0c\u6211\u5c06\u6f14\u793a\u5982\u4f55\u4f7f\u7528GPIO\u8ba9LED\u6bcf\u79d2\u95ea\u70c1\u4e00\u6b21\u3002<\/p>\n<p><strong>\u9884\u8ba1\u5b8c\u6210\u65f6\u95f4\uff1a45 \u5206\u949f \u2014 1\u5c0f\u65f6\u3002<\/strong><\/p>\n<h2>\u9700\u51c6\u5907\u7684\u96f6\u4ef6\u548c\u8bbe\u5907<\/h2>\n<ul>\n<li>Raspberry Pi 3 \u578b\u53f7 B<\/li>\n<li>Micro SD \u5361<\/li>\n<li>Micro USB \u6570\u636e\u7ebf<\/li>\n<li>\u952e\u76d8<\/li>\n<li>\u9f20\u6807<\/li>\n<li>\u76d1\u63a7\u5668<\/li>\n<li>LED \u706f<\/li>\n<li>\u7535\u963b\u5668<\/li>\n<li>\u9762\u5305\u677f<\/li>\n<li>\u8df3\u7ebf<\/li>\n<li>\u7535\u8111\u4e0e\u4e92\u8054\u7f51\u8fde\u63a5<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>\u76ee\u5f55<\/strong><\/p>\n<ol>\n<li>\u8bbe\u7f6e\u60a8\u7684 Raspberry Pi\n<ol>\n<li>\u6b63\u5728\u4e0b\u8f7d NOOB<\/li>\n<li>\u683c\u5f0f\u5316Micro SD\u5361\uff08\u53ef\u9009\uff09<\/li>\n<li>\u9996\u6b21\u542f\u52a8\u5e76\u5b89\u88c5 Raspbian<\/li>\n<\/ol>\n<\/li>\n<li>\u7ed8\u5236\u7535\u8def<\/li>\n<li>\u8ba9LED\u95ea\u70c1\n<ol>\n<li>\u7f16\u5199\u811a\u672c\u7a0b\u5e8f<\/li>\n<li>\u8fd0\u884c\u811a\u672c\u7a0b\u5e8f<\/li>\n<\/ol>\n<\/li>\n<li>\u9644\u5f55\uff1aLED_flash.py\uff08Python\u811a\u672c\uff09<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2>1) \u8bbe\u7f6e\u60a8\u7684 Raspberry Pi\uff1a\u4e0b\u8f7d NOOBS<\/h2>\n<p>\u6b63\u5982\u6211\u5728\u6982\u8ff0\u4e2d\u6240\u8ff0\uff0cRaspberry Pis\u662f\u914d\u6709\u64cd\u4f5c\u7cfb\u7edf\u7684\u5fae\u578b\u8ba1\u7b97\u673a\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5b89\u88c5OS Raspbian\u3002Raspbian\u662f\u4e00\u5957\u83b7\u5f97\u4e86Raspberry\u793e\u533a\u652f\u6301\u7684\u57fa\u4e8eLinux\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\u662f\u4ece\u4ee5\u4e0b\u7f51\u5740\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684NOOBS\uff08New Out Of Box\u8f6f\u4ef6\uff09\uff1a<a href=\"https:\/\/www.raspberrypi.org\/downloads\/noobs\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.raspberrypi.org\/downloads\/noobs\/<\/a>\u3002NOOBS\u662f\u64cd\u4f5c\u7cfb\u7edf\u5b89\u88c5\u7a0b\u5e8f\uff0c\u7528\u4e8e\u5728Raspberry Pi\u4e0a\u5b89\u88c5\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p><strong>\u6ce8\uff1a<\/strong>\u5982\u679c\u60a8\u8d2d\u4e70\u7684micro SD\u5361\u9884\u5148\u5b89\u88c5\u4e86NOOBS\uff0c\u5219\u53ef\u4ee5\u8df3\u8fc7\u6b64\u6b65\u9aa4\u4ee5\u53ca\u4e0b\u4e00\u6b65\u3002<\/p>\n<p>\u5982\u679c\u60a8\u7684micro SD\u5361\u662f\u65b0\u7684\uff0c\u5219\u53ef\u80fd\u9700\u8981\u5c06\u5176\u683c\u5f0f\u5316\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528SD Card Formatter 4.0\u6267\u884c\u6b64\u64cd\u4f5c\u3002\u6b64\u6b65\u9aa4\u4e3a\u53ef\u9009\u3002<\/p>\n<p>\u5b89\u88c5NOOBS\u5e76\u683c\u5f0f\u5316SD\u5361\u540e\uff0c\u60a8\u53ef\u4ee5\u5c06\u63d0\u53d6\u7684\u6240\u6709NOOBS\u6587\u4ef6\u590d\u5236\u5230SD\u5361\u3002\u52a1\u5fc5\u590d\u5236\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u8bf7\u52ff\u53ea\u590d\u5236\u6587\u4ef6\u5939\u672c\u8eab\uff0c\u5426\u5219NOOBS\u5c06\u65e0\u6cd5\u542f\u52a8\u3002\u4ece\u8ba1\u7b97\u673a\u4e2d\u53d6\u51faSD\u5361\u5e76\u5c06\u5176\u63d2\u5165Raspberry Pi\u3002<\/p>\n<div id=\"attachment_6955\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6955\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi.jpg\" alt=\"DIY Raspberry Pi\" width=\"700\" height=\"949\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi-221x300.jpg 221w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi-108x146.jpg 108w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi-37x50.jpg 37w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_fig1Raspberry-Pi-55x75.jpg 55w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe1\uff1aRaspberry Pi<\/p>\n<\/div>\n<p>\u60a8\u73b0\u5728\u53ef\u4ee5\u7b2c\u4e00\u6b21\u542f\u52a8Raspberry Pi\u4e86\u3002\u5c06\u952e\u76d8\u3001\u9f20\u6807\u548c\u663e\u793a\u5668\u8fde\u63a5\u5230Raspberry Pi\uff08\u56fe1\uff1aRaspberry Pi\uff09\u3002\u63d2\u5165USB\u6570\u636e\u7ebf\u4e3aRaspberry Pi\u4f9b\u7535\uff1b\u60a8\u7684Pi\u5c06\u542f\u52a8\u5e76\u51fa\u73b0\u4e00\u4e2a\u7a97\u53e3\uff08\u56fe2\uff1aNOOBS\u521d\u59cb\u5316\u753b\u9762\uff09\u3002\u7a97\u53e3\u4e2d\u4f1a\u5217\u51fa\u5907\u9009\u5b89\u88c5\u7684\u6240\u6709\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u3002\u5b89\u88c5Raspbian Lite\uff0c\u9009\u4e2d\u590d\u9009\u6846\u4ee5\u9009\u62e9Raspbian Lite\uff0c\u7136\u540e\u5355\u51fb\u201c\u5b89\u88c5\u201d\uff08\u56fe3\uff1a\u64cd\u4f5c\u7cfb\u7edf\u5b89\u88c5\u9009\u9879\uff08NOOBS\uff09\uff09\u3002NOOBS\u5373\u5c06\u5b89\u88c5Raspbian Lite\u3002\u8bf7\u8010\u5fc3\u7b49\u5019\uff1b\u53ef\u80fd\u9700\u898110-20\u5206\u949f\u3002<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u60a8\u767b\u5f55\u3002Raspbian\u7684\u9ed8\u8ba4\u767b\u5f55\u540d\u5373\u7528\u6237\u540d\uff1api\uff0c\u5bc6\u7801\uff1araspberry\u3002\u6ce8\uff1a\u8f93\u5165\u5bc6\u7801\u65f6\uff0c\u60a8\u5c06\u770b\u4e0d\u5230\u8f93\u5165\u7684\u5b57\u7b26\u3002\u672c\u6559\u7a0b\u4e2d\u7684\u5176\u4f59\u5185\u5bb9\u5c06\u901a\u8fc7\u547d\u4ee4\u884c\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n<div id=\"attachment_6953\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6953\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen.jpg\" alt=\"raspberry-pi Fig2 NOOBS Initialization Screen\" width=\"700\" height=\"517\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen-300x222.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen-198x146.jpg 198w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen-50x37.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig2-NOOBS-Initialization-Screen-102x75.jpg 102w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe2\uff1aNOOBS\u521d\u59cb\u5316\u753b\u9762<\/p>\n<\/div>\n<div id=\"attachment_6957\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6957\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS.jpg\" alt=\"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi \u56fe3\" width=\"700\" height=\"565\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS-300x242.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS-181x146.jpg 181w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS-50x40.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig3-OS-Install-Selection-NOOBS-93x75.jpg 93w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe3\uff1a\u64cd\u4f5c\u7cfb\u7edf\u5b89\u88c5\u9009\u9879\uff08NOOBS\uff09<\/p>\n<\/div>\n<div id=\"attachment_6958\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6958\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite.jpg\" alt=\"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi \u56fe4\" width=\"700\" height=\"576\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite-300x247.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite-177x146.jpg 177w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite-50x41.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig4-NOOBS-Installing-Raspbian-Lite-91x75.jpg 91w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe4\uff1a\u5728NOOBS\u4e0a\u5b89\u88c5Raspbian Lite<\/p>\n<\/div>\n<h2>2) \u7ed8\u5236\u7535\u8def<\/h2>\n<p>\u5f85\u7ed8\u5236\u7684\u7535\u8def\u5f88\u7b80\u5355\u3002\u6211\u6b63\u5728\u4f7f\u7528\u9762\u5305\u677f\u642d\u5efa\u7535\u8def\uff1b\u968f\u610f\u5c06\u7ec4\u4ef6\u710a\u63a5\u5728\u4e00\u8d77\uff0c\u6216\u8005\u4e3aRaspberry Pi\u5236\u4f5c\u4e00\u4e2a\u539f\u578b\u6269\u5c55\u677f\u3002\u6211\u559c\u6b22\u5148\u7ed8\u5236\u597d\u7535\u8def\u7684Fritzing\u7535\u8def\u56fe\uff08\u56fe5\uff1aFritzing\u7535\u8def\u56fe\uff09\u3002Fritzing\u662f\u4e00\u79cd\u5f00\u6e90\u5f0f\u539f\u7406\u56fe\u8bc6\u522b\u548cPCB\u5e03\u7ebf\u8f6f\u4ef6\u3002\u767b\u9646\u4ee5\u4e0b\u7f51\u5740\u53ef\u4e0b\u8f7dFritzing\uff1a<a href=\"https:\/\/fritzing.org\/home\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/fritzing.org\/home\/<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6959\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic.jpg\" alt=\"Figure 5: Fritzing Schematic\" width=\"700\" height=\"624\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic-300x267.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic-164x146.jpg 164w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic-50x45.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig5-Fritzing-Schematic-84x75.jpg 84w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p>LED\u548c\u7535\u963b\u5668\u5e94\u4e32\u8054\u5728\u5f15\u811a11\uff08GPIO17\uff09\u548c\u5f15\u811a25\uff08\u63a5\u5730\uff09\u4e4b\u95f4\u3002\u7535\u963b\u5668\u7528\u4e8e\u9650\u5236\u901a\u8fc7LED\u7684\u7535\u6d41\uff0c\u5e76\u5e94\u6839\u636eLED\u7684\u5927\u5c0f\u8fdb\u884c\u76f8\u5e94\u8c03\u6574\uff0c\u4ee5\u9632\u70e7\u574f\u3002\u8bf7\u8bb0\u4f4fLED\u4e0a\u7684\u8f83\u957f\u5f15\u7ebf\u4e3a\u6b63\u6781\uff0c\u5e94\u8fde\u63a5\u5230\u5f15\u811a11\u3002<\/p>\n<h2>3) \u7f16\u5199\u4ee3\u7801<\/h2>\n<p>\u82e5\u60f3\u4f7fLED\u95ea\u70c1\uff0c\u9700\u8981\u7f16\u5199\u5e76\u8fd0\u884cPython\u811a\u672c\u3002Python\u662f\u4e00\u79cd\u7f16\u8bd1\u8fc7\u7684\u7a0b\u5e8f\u8bed\u8a00\u3002\u6211\u4e0d\u6253\u7b97\u5728\u672c\u6559\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecdPython\uff0c\u4f46\u662f\u6211\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u5728Raspberry Pi\u4e0a\u7528Python\u7f16\u5199\u811a\u672c\u7136\u540e\u8fd0\u884c\u811a\u672c\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u5229\u7528\u4e0a\u8ff0\u77e5\u8bc6\u5728Python\u4e2d\u7f16\u5199\u5176\u4ed6\u811a\u672c\uff0c\u5e76\u5728Raspberry Pi\u4e2d\u4f7f\u7528GPIO\u3002\u5728\u8fdb\u884c\u4e0b\u4e00\u6b65\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684Raspberry Pi\u5df2\u8fde\u63a5\u5230Internet\u3002<\/p>\n<p>\u9996\u5148\u786e\u4fdd\u60a8\u62e5\u6709\u6700\u65b0\u7248\u672c\u7684RPi.GPIO\u3002RPi.GPIO\u662f\u4e00\u4e2aPython\u5e93\uff0c\u7528\u4e8e\u63a7\u5236Raspberry Pi GPIO\u5f15\u811a\u3002\u8981\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u8bf7\u5728\u547d\u4ee4\u884c\u4e2d\u952e\u5165\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\uff1a<\/p>\n<p><!-- Crayon Syntax Highlighter v_2.7.2_beta --><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>$ sudo apt-get update\n$ sudo apt-get install python-rpi.gpio python3-rpi.gpio\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u66f4\u65b0\u4e86RPi.GPIO\u4e4b\u540e\uff0c\u60a8\u5c31\u53ef\u4ee5\u5236\u4f5c\u4e00\u4e2aPython\u811a\u672c\u6587\u4ef6\u3002\u6211\u5c06\u5176\u547d\u540d\u4e3a\u201cLED_blink\u201d\uff0c\u4f46\u4e0d\u786e\u5b9a\u662f\u5426\u66fe\u7ecf\u8d77\u4e86\u53e6\u4e00\u4e2a\u540d\u5b57\u3002\u8981\u521b\u5efa\u6587\u4ef6\uff0c\u8bf7\u5728\u547d\u4ee4\u884c\u4e2d\u952e\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p><!-- Crayon Syntax Highlighter v_2.7.2_beta --><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>$ nano LED_blink.py\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u60a8\u5c06\u8fdb\u5165\u811a\u672c\u7f16\u8f91\u7684\u65b0\u7a97\u53e3\u3002\u5c06\u9644\u5f55\u4e2d\u7684\u811a\u672c\u590d\u5236\u5230\u7f16\u8f91\u5668\u4e2d\u5e76\u4fdd\u5b58\u6587\u4ef6\u3002<\/p>\n<div id=\"attachment_6962\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6962\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line.jpg\" alt=\"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi \u56fe6\" width=\"700\" height=\"212\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line-300x91.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line-260x79.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line-50x15.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig6-Running-the-Script-from-Command-Line-150x45.jpg 150w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe6\uff1a\u4ece\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c<\/p>\n<\/div>\n<p>\u73b0\u5728\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff08\u56fe6\uff1a\u4ece\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c\uff09\uff1a<\/p>\n<p><!-- Crayon Syntax Highlighter v_2.7.2_beta --><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>$ sudo python flash_LED.py\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>\u73b0\u5728\uff0cLED\u5e94\u8be5\u5b9e\u73b0\u4e86\u6bcf\u79d2\u95ea\u70c1\uff0c\u5373\u6bcf\u79d2\u7184\u706d\uff08\u56fe7\uff1aLED\u7184\u706d\uff09\u548c\u4eae\u8d77\uff08\u56fe8\uff1aLED\u4eae\u8d77\uff09\u3002\u6b32\u505c\u6b62\u8fd0\u884c\u811a\u672c\uff0c\u8bf7\u6309\u952e\u76d8\u4e0a\u7684\u201cCTRL + C\u201d\u3002<\/p>\n<p>\u606d\u559c\u60a8\uff01\u60a8\u7684Raspberry Pi\u5df2\u8bbe\u7f6e\u5b8c\u6210\u5e76\u6b63\u5728\u8fd0\u884c\u3002\u60a8\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u8fd0\u884c\u811a\u672c\u6216\u5176\u4ed6\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002<\/p>\n<div id=\"attachment_6963\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6963\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off.jpg\" alt=\"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi \u56fe7\" width=\"700\" height=\"724\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off-290x300.jpg 290w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off-141x146.jpg 141w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off-48x50.jpg 48w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig7-LED-Off-73x75.jpg 73w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe7\uff1aLED\u7184\u706d<\/p>\n<\/div>\n<div id=\"attachment_6964\" style=\"width: 710px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-6964\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On.jpg\" alt=\"DIY\u6280\u5de7\uff1a\u5982\u4f55\u8bbe\u7f6e\u60a8\u7684Raspberry Pi \u56fe8\" width=\"700\" height=\"724\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On-290x300.jpg 290w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On-141x146.jpg 141w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On-48x50.jpg 48w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2018\/02\/raspberry-pi_Fig8-LED-On-73x75.jpg 73w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\"><\/p>\n<p class=\"wp-caption-text\">\u56fe8\uff1aLED\u4eae\u8d77<\/p>\n<\/div>\n<h2>4) \u9644\u5f55\uff1aLED_Flash.py (Python Script)<\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><b>import<\/b> <span style=\"font-weight: 400;\">RPi<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">GPIO<\/span> <b>as<\/b> <span style=\"font-weight: 400;\">GPIO<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>import<\/b><span style=\"font-weight: 400;\"> time<\/span><\/li>\n<li style=\"font-weight: 400;\"><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\"> = <\/span><span style=\"font-weight: 400;\">11<\/span> <span style=\"font-weight: 400;\"># pin11<\/span><\/li>\n<li style=\"font-weight: 400;\"><\/li>\n<li style=\"font-weight: 400;\"><b>def<\/b><span style=\"font-weight: 400;\"> setup<\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\">:<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">setmode<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">BOARD<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># Numbers GPIOs by physical location<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">setup<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">OUT<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># Set LedPin\u2019s mode is output<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">HIGH<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># Set LedPin high(+3.3V) to turn on led<\/span><\/li>\n<li style=\"font-weight: 400;\"><\/li>\n<li style=\"font-weight: 400;\"><b>def<\/b><span style=\"font-weight: 400;\"> blink<\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\">:<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>while<\/b> <span style=\"font-weight: 400;\">True<\/span><span style=\"font-weight: 400;\">:<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">HIGH<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># led on<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">time.<\/span><span style=\"font-weight: 400;\">sleep<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">LOW<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># led off<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">time.<\/span><span style=\"font-weight: 400;\">sleep<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">1<\/span><span style=\"font-weight: 400;\">)<\/span><\/li>\n<li style=\"font-weight: 400;\"><\/li>\n<li style=\"font-weight: 400;\"><b>def<\/b><span style=\"font-weight: 400;\"> destroy<\/span><span style=\"font-weight: 400;\">()<\/span><span style=\"font-weight: 400;\">:<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">output<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">LedPin<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">LOW<\/span><span style=\"font-weight: 400;\">)<\/span> <span style=\"font-weight: 400;\"># led off<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GPIO<\/span><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">cleanup<\/span><span style=\"font-weight: 400;\">()<\/span> <span style=\"font-weight: 400;\"># Release resource<\/span><\/li>\n<li style=\"font-weight: 400;\"><\/li>\n<li style=\"font-weight: 400;\"><b>if<\/b><span style=\"font-weight: 400;\"> __name__ == <\/span><span style=\"font-weight: 400;\">\u2018__main__\u2019<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\"># Program start from here<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">setup<\/span><span style=\"font-weight: 400;\">()<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>try<\/b><span style=\"font-weight: 400;\">:<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">blink<\/span><span style=\"font-weight: 400;\">()<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>except<\/b> <span style=\"font-weight: 400;\">KeyboardInterrupt<\/span><span style=\"font-weight: 400;\">: <\/span><span style=\"font-weight: 400;\"># When \u2018Ctrl+C\u2019 is pressed, the child program destroy() will be executed.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">destroy<\/span><span style=\"font-weight: 400;\">()<\/span><\/li>\n<\/ol>\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\/2018\/08\/Device-Plus-logo-for-author-info-75x75.png\" width=\"64\" height=\"64\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\"><\/div>\n<div class=\"desc-wrapper\">\n<h5>DevicePlus \u7f16\u8f91\u56e2\u961f<\/h5>\n<div class=\"desc\">\n<p>\u8bbe\u5907\u5347\u7ea7\u7248\u9002\u7528\u4e8e\u6240\u6709\u70ed\u7231\u7535\u5b50\u548c\u673a\u7535\u4e00\u4f53\u5316\u7684\u4eba\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 \u6982\u8ff0 Raspberry Pi\u662f\u9002\u5408DIYers\u3001\u4e1a\u4f59\u7231\u597d\u8005\u548c\u5b66\u751f\u4f7f\u7528\u7684\u5355\u677f\u673a\u7cfb\u5217\u3002\u8be5\u7cfb\u5217\u4ea7\u54c1\u7684\u95ee\u4e16\u65e8\u5728\u4fc3\u8fdb\u5168\u4e16\u754c\u7684\u8ba1\u7b97\u673a\u5b66\u79d1\u6559\u80b2\u3002Arduino\u548cRaspb [&hellip;]","protected":false},"author":3,"featured_media":21049,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1132],"tags":[],"class_list":["post-6890","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\/6890","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=6890"}],"version-history":[{"count":6,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/6890\/revisions"}],"predecessor-version":[{"id":21050,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/6890\/revisions\/21050"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/21049"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=6890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=6890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=6890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}