{"id":457,"date":"2019-05-01T00:00:20","date_gmt":"2019-04-30T16:00:20","guid":{"rendered":"https:\/\/www.wxbit.com\/?p=457"},"modified":"2019-06-05T15:16:46","modified_gmt":"2019-06-05T07:16:46","slug":"%e4%bb%a5-arduino-%e4%b9%8b%e5%90%8d%ef%bc%8c%e7%82%b9%e4%ba%aeled%e5%bd%a9%e7%81%af","status":"publish","type":"post","link":"https:\/\/www.wxbit.com\/?p=457","title":{"rendered":"\u4ee5 Arduino \u4e4b\u540d\uff0c\u70b9\u4eae LED \u706f"},"content":{"rendered":"<p>Arduino\u00a0\u662f\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684\u8f6f\u786c\u4ef6\u5f00\u653e\u5e73\u53f0\uff0c\u5305\u62ec\u786c\u4ef6 \u2014\u2014\u00a0\u591a\u79cd\u578b\u53f7\u7684 Arduino\u00a0\u5f00\u53d1\u677f\u53ca\u6269\u5c55\u677f\uff0c\u548c\u8f6f\u4ef6 \u2014\u2014 Arduino IDE\u3002\u5728\u201c\u521b\u5ba2\u201d\u6559\u5b66\u5982\u706b\u5982\u837c\u8fdb\u884c\u7684\u5f53\u4e0b\uff0cArduino\u00a0\u7684\u540d\u5b57\u5982\u96f7\u8d2f\u8033\u3002\u867d\u7136\u5f88\u591a\u540c\u5b66\u542c\u8fc7\uff0c\u5374\u4e0d\u4e00\u5b9a\u7528\u8fc7\u3002\u672c\u7cfb\u5217\u6559\u7a0b\uff0c\u6768\u8001\u5e08\u8ddf\u540c\u5b66\u4eec\u4ece\u96f6\u5f00\u59cb\u4e0a\u624b Arduino IDE\uff0c\u7136\u540e\u5b66\u4e60\u4f7f\u7528 App Inventor 2 WxBit\u00a0\u6c49\u5316\u7248\u4e0e\u5f00\u53d1\u677f\u4ea4\u4e92\u3002\u672c\u7bc7\u6559\u7a0b\u4e2d\u6211\u4eec\u5e76\u4e0d\u4f7f\u7528 Arduino\u00a0\u5f00\u53d1\u677f\uff0c\u53ea\u501f\u7528 Arduino\u00a0IDE \u6765\u7ed9\u6211\u4eec\u7684 ESP32\u00a0\u5f00\u53d1\u677f\u5199\u5165\u56fa\u4ef6\uff0c\u4ee5 Arduino\u00a0\u4e4b\u540d\uff0c\u70b9\u4eaeLED\u706f\u3002\u9009\u62e9 Arduino\u00a0IDE \u662f\u56e0\u4e3a\u64cd\u4f5c\u6b65\u9aa4\u7b80\u5355\uff0c\u7528\u5176\u4ed6\u5de5\u5177\u5199\u5165\u56fa\u4ef6\u4e5f\u6ca1\u95ee\u9898\uff0c\u4e0d\u5728\u672c\u6559\u7a0b\u8ba8\u8bba\u3002<\/p>\n<p>\u76f8\u6bd4\u52a8\u8f8499\uff0c\u4e0a\u767e\u5143\u7684\u5165\u95e8\u5b66\u4e60\u5957\u4ef6\uff0c\u672c\u6559\u7a0b\u6240\u7528\u7684\u5143\u4ef6\u4ef7\u683c\u4fbf\u5b9c\uff0c\u54c1\u8d28\u4e0d\u6253\u6298\u6263\u3002\u91c7\u8d2d\u5b89\u4fe1\u53efNodeMCU-32S\uff08ESP32\uff09\u5f00\u53d1\u677f\uff08\uffe518.7\uff09\uff0cMB-102\u9762\u5305\u677f\uff08\uffe54.5\uff09\u3001KY-009 LED \u6a21\u5757\uff08\uffe50.79\uff09\u300140P \u5f69\u8272\u516c\u5bf9\u516c\u675c\u90a6\u7ebf\uff08\uffe51.6\uff09\uff0c\u52a0\u4e0a4\u5143\u90ae\u8d39\u603b\u8ba130\u5143\uff0c\u5373\u53ef\u5f00\u59cb\u201cArduino\u201d\u4e4b\u65c5\u3002\u6709\u5174\u8da3\u6df1\u5165\u5b66\u4e60\u7684\u540c\u5b66\uff0c\u8fd8\u53ef\u4ee5\u987a\u5e26\u8d2d\u4e70DHT11\u6e29\u6e7f\u5ea6\u4f20\u611f\u5668\u6a21\u5757\u3001\u8702\u9e23\u5668\u6a21\u5757\u3001\u5149\u654f\u7535\u963b\u6a21\u5757\u3001\u7ea2\u5916\u53d1\u5c04\/\u63a5\u6536\u6a21\u5757\u7b49\uff0c<span style=\"color: #ff0000;\">\u5e26\u710a\u9488\uff08\u6572\u9ed1\u677f\uff0c\u5212\u91cd\u70b9\uff09<\/span>\u65b9\u4fbf\u63d2\u5728\u9762\u5305\u677f\u4e0a\u4f7f\u7528\u7684\u6a21\u5757\u3002\u60f3\u8282\u7701\u6210\u672c\uff0c\u53ef\u4ee5\u7701\u6389\u9762\u5305\u677f\u76f4\u63a5\u4f7f\u7528\u6bcd\u5bf9\u6bcd\u675c\u90a6\u7ebf\u8fde\u63a5\u6a21\u5757\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-512\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"947\" height=\"656\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-512\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic.png\" alt=\"\" width=\"947\" height=\"656\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic.png 947w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic-300x208.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic-768x532.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/electronic-624x432.png 624w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/p><\/noscript>\n<p>\u62ff\u5230\u5143\u4ef6\u540e\uff0c\u5c06ESP32\u82af\u7247\u548cLED\u6a21\u5757\u63d2\u5165\u9762\u5305\u677f\uff0c\u5e76\u7528\u675c\u90a6\u7ebf\u8fde\u597d\u5907\u7528\uff0c\u6548\u679c\u89c1\u4e0a\u56fe\u53f3\u4e0b\u89d2\u3002LED\u6a21\u5757\u7684RGB\u9488\u811a\u5206\u522b\u4e0e\u82af\u7247\u768427\u300126\u300125\u9488\u811a\u8fde\u63a5\uff0c\u201c-\u201d\u5219\u8fde\u63a5\u82af\u7247\u7684GND\u5730\u7ebf\u3002\u9762\u5305\u677f\u4e2d\u95f4\u533a\u57df\u7ad6\u54115\u4e2a\u5b54\u8fde\u901a\uff0c\u5916\u8fb9\u7f18\u6a2a\u54115\u4e2a\u5b54\u8fde\u901a\uff0c\u7528\u6cd5\u7b80\u5355\u4e0d\u518d\u8d58\u8ff0\u3002\u5f00\u53d1\u677f\u8be6\u7ec6\u4ecb\u7ecd\uff1a<a href=\"https:\/\/wiki.ai-thinker.com\/esp32\/boards\/nodemcu_32s\" target=\"_blank\"  rel=\"nofollow\" >NodeMCU-32S \u6838\u5fc3\u5f00\u53d1\u677f<\/a>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-492\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"889\" height=\"702\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-492\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32.png\" alt=\"\" width=\"889\" height=\"702\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32.png 889w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32-300x237.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32-768x606.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32-624x493.png 624w\" sizes=\"auto, (max-width: 889px) 100vw, 889px\" \/><\/p><\/noscript>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-493\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"868\" height=\"923\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-493\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin.png\" alt=\"\" width=\"868\" height=\"923\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin.png 868w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin-282x300.png 282w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin-768x817.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/nodemcu_32s_pin-624x664.png 624w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/p><\/noscript>\n<p>\u63a5\u4e0b\u6765\u51c6\u5907\u7f16\u5199\u82af\u7247\u56fa\u4ef6\uff0cArduino IDE \u767b\u573a\u3002<\/p>\n<p>\u9996\u5148\uff0c\u4e0b\u8f7d\u5b89\u88c5 Arduino IDE\uff0c<a href=\"https:\/\/dev.tencent.com\/u\/daoquan\/p\/arduino\/git\/raw\/master\/ide\/arduino-1.8.9-windows.exe\" target=\"_blank\"  rel=\"nofollow\" >Windows 8.1\/10\u00a0<\/a>\uff0c<a href=\"https:\/\/dev.tencent.com\/u\/daoquan\/p\/arduino\/git\/raw\/master\/ide\/arduino-1.8.9-macosx.zip\" target=\"_blank\"  rel=\"nofollow\" >Mac OSX<\/a>\u3002Windows\u5b89\u88c5\u5305\u81ea\u5e26USB\u9a71\u52a8\uff0c\u5982\u679c\u662fMac\u7cfb\u7edf\uff0c\u8fd8\u9700\u53e6\u5916\u4e0b\u8f7dUSB\u9a71\u52a8\u5b89\u88c5\uff0c<a href=\"https:\/\/cdn.sparkfun.com\/assets\/learn_tutorials\/7\/4\/FTDIUSBSerialDriver_v2_4_2.dmg\" target=\"_blank\"  rel=\"nofollow\" >\u70b9\u51fb\u4e0b\u8f7d<\/a>\u3002Windows\u5b89\u88c5USB\u9a71\u52a8\u65f6\u4f1a\u5f39\u51fa\u5b89\u5168\u63d0\u793a\uff0c\u4e00\u5b9a\u8981\u9009\u62e9<span style=\"color: #ff0000;\">\u201c\u5b89\u88c5\u201d<\/span>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-488\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"959\" height=\"292\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-488\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install.png\" alt=\"\" width=\"959\" height=\"292\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install.png 959w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-300x91.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-768x234.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-624x190.png 624w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/p><\/noscript>\n<p>\u5b89\u88c5\u5b8c\u542f\u52a8 Arduino IDE\uff0c\u770b\u5230\u56fa\u4ef6\u5f00\u53d1\u53ca\u4e0a\u4f20\uff08\u70e7\u5199\u56fa\u4ef6\u5230\u82af\u7247\uff09\u754c\u9762\u3002\u4ee3\u7801\u7f16\u8f91\u7a97\u53e3\u4e2d\u7684 setup\u00a0\u51fd\u6570\u5728\u5f00\u53d1\u677f\u542f\u52a8\u65f6\u6267\u884c\u4e00\u6b21\uff0cloop\u5219\u662f\u4e00\u4e2a\u65e0\u9650\u5faa\u73af\uff0c\u5f00\u53d1\u677f\u5bf9\u786c\u4ef6\u7684\u8bfb\u5199\u63a7\u5236\u903b\u8f91\uff0c\u4e00\u822c\u90fd\u653e\u5728\u8fd9\u91cc\u5b9e\u73b0\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-486\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"902\" height=\"660\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-486\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide.png\" alt=\"\" width=\"902\" height=\"660\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide.png 902w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide-300x220.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide-768x562.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-ide-624x457.png 624w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/p><\/noscript>\n<p>\u4e3a\u4e86\u652f\u6301 ESP32\u00a0\u7684\u56fa\u4ef6\u5f00\u53d1\uff0c\u5148\u5728\u6587\u4ef6\u83dc\u5355\u9996\u9009\u9879\u8bbe\u7f6e\u4e2d\u6dfb\u52a0ESP32\u5f00\u53d1\u677f\u7684\u652f\u6301\u3002<br \/>\n\u5728\u5f00\u53d1\u677f\u7ba1\u7406\u7f51\u7ad9\u4e2d\u8f93\u5165\uff1ahttps:\/\/github.com\/espressif\/arduino-esp32\/releases\/download\/1.0.2\/package_esp32_index.json<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-484\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"900\" height=\"658\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-484\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp.png\" alt=\"\" width=\"900\" height=\"658\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp.png 900w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp-300x219.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp-768x561.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp-624x456.png 624w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p><\/noscript>\n<p>\u63a5\u4e0b\u6765\u5728\u5f00\u53d1\u677f\u7ba1\u7406\u5668\u4e2d\u5b89\u88c5ESP32\u7684\u914d\u7f6e\uff0c\u7136\u540e\u9009\u62e9\u201cESP32 Dev Module\u201d\uff0c\u5176\u4ed6\u9009\u9879\u4fdd\u7559\u9ed8\u8ba4\u503c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-480\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"903\" height=\"661\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-480\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32.png\" alt=\"\" width=\"903\" height=\"661\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32.png 903w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32-300x220.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32-768x562.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-install-esp32-624x457.png 624w\" sizes=\"auto, (max-width: 903px) 100vw, 903px\" \/><\/p><\/noscript>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-482\" data-original=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected.png\" src=\"https:\/\/www.wxbit.com\/wp-content\/themes\/wxbit\/images\/loading.gif\" alt=\"\" width=\"902\" height=\"660\" \/><\/p>\n<noscript><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-482\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected.png\" alt=\"\" width=\"902\" height=\"660\" srcset=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected.png 902w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected-300x220.png 300w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected-768x562.png 768w, https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/04\/arduino-esp32-selected-624x457.png 624w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/p><\/noscript>\n<p>\u5230\u8fd9\u4e00\u6b65\uff0c\u4f7f\u7528 Arduino IDE \u5f00\u53d1 ESP32\u00a0\u56fa\u4ef6\u7684\u51c6\u5907\u5de5\u4f5c\u5b8c\u6210\u3002\u4f7f\u7528Micro USB\u6570\u636e\u7ebf<span style=\"color: #ff0000;\">\u8fde\u63a5\u5f00\u53d1\u677f\u5230\u7535\u8111\u524d<\/span>\uff0c\u5148\u770b\u770b\u4e0a\u56fe\u201c\u7aef\u53e3\u201d\u4e2d\u7684\u6709\u90a3\u4e9b\u4e32\u53e3\uff0c\u8fde\u7ebf\u540e\u4f1a\u589e\u52a0\u4e00\u4e2a\uff0c\u5c31\u662f\u6211\u4eec\u7684\u5f00\u53d1\u677f\u3002\u9009\u62e9\u8be5\u4e32\u53e3\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u56fa\u4ef6\u4ee3\u7801\uff0c\u5176\u5b9e\u662f\u201c\u590d\u5236\u201d\u4e0e\u201c\u7c98\u5e16\u201d\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre style=\"padding-left: 30px;\"><span style=\"color: #434f54;\">\/\/ \u5c06LED\u706f\u7684RGB\u811a\u5206\u522b\u8fde\u5230\u82af\u7247\u7684 25\u300126\u300127 \u811a\uff0c\r\n<\/span><span style=\"color: #434f54;\">\/\/ <span style=\"color: #ff6600;\">\u90e8\u5206LED\u6a21\u5757\u7684R\u548cG\u9488\u811a\u6807\u6ce8\u9519\u8bef\uff0c\u5e94\u8c03\u6362\u914d\u7f6e\uff0cPIN_R \u914d\u7f6e\u4e3a 26<\/span><\/span>\r\n<span style=\"color: #00979c;\">const<\/span> <span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">PIN_R<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">27<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #00979c;\">const<\/span> <span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">PIN_G<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">26<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #00979c;\">const<\/span> <span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">PIN_B<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">25<\/span><span style=\"color: #000000;\">;<\/span>\r\n\r\n<span style=\"color: #00979c;\">void<\/span> <span style=\"color: #5e6d03;\">setup<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span> <span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #434f54;\">\/\/ \u5c06LED\u811a\u6620\u5c04\u5230\u901a\u9053\u5e76\u521d\u59cb\u5316<\/span>\r\n \u00a0<span style=\"color: #000000;\">setupLed<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span>\r\n\r\n<span style=\"color: #00979c;\">void<\/span> <span style=\"color: #5e6d03;\">loop<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span> <span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #434f54;\">\/\/ \u6539\u53d8LED\u7684\u989c\u8272<\/span>\r\n \u00a0<span style=\"color: #000000;\">changeLedColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #434f54;\">\/\/ \u5ef6\u8fdf0.01\u79d2<\/span>\r\n \u00a0<span style=\"color: #d35400;\">delay<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">10<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span>\r\n\r\n<span style=\"color: #00979c;\">void<\/span> <span style=\"color: #000000;\">setupLed<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcAttachPin<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">PIN_R<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">1<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcAttachPin<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">PIN_G<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">2<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcAttachPin<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">PIN_B<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">3<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcSetup<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">1<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">5000<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">8<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcSetup<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">2<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">5000<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">8<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcSetup<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">3<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">5000<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">8<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span>\r\n<span style=\"color: #434f54;\">\/\/ \u8bbe\u7f6e\u968f\u673a\u521d\u59cb\u989c\u8272<\/span>\r\n<span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">red<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">randomColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">green<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">randomColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">blue<\/span> <span style=\"color: #434f54;\">=<\/span> <span style=\"color: #000000;\">randomColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">randomColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #5e6d03;\">return<\/span> <span style=\"color: #d35400;\">random<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">0<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">256<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span>\r\n<span style=\"color: #00979c;\">void<\/span> <span style=\"color: #000000;\">changeLedColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">)<\/span> <span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcWrite<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">1<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">gradientColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">red<\/span><span style=\"color: #434f54;\">++<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcWrite<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">2<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">gradientColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">green<\/span><span style=\"color: #434f54;\">++<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n \u00a0<span style=\"color: #000000;\">ledcWrite<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">3<\/span><span style=\"color: #434f54;\">,<\/span> <span style=\"color: #000000;\">gradientColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #000000;\">blue<\/span><span style=\"color: #434f54;\">++<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">)<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span>\r\n<span style=\"color: #434f54;\">\/\/ \u6e10\u53d8\u989c\u8272<\/span>\r\n<span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">gradientColor<\/span><span style=\"color: #000000;\">(<\/span><span style=\"color: #00979c;\">uint8_t<\/span> <span style=\"color: #000000;\">color<\/span><span style=\"color: #000000;\">)<\/span> <span style=\"color: #000000;\">{<\/span>\r\n \u00a0<span style=\"color: #5e6d03;\">return<\/span> <span style=\"color: #000000;\">color<\/span> <span style=\"color: #434f54;\">&lt;=<\/span> <span style=\"color: #000000;\">128<\/span> <span style=\"color: #434f54;\">?<\/span> <span style=\"color: #000000;\">color<\/span> <span style=\"color: #434f54;\">:<\/span> <span style=\"color: #000000;\">256<\/span> <span style=\"color: #434f54;\">-<\/span> <span style=\"color: #000000;\">color<\/span><span style=\"color: #000000;\">;<\/span>\r\n<span style=\"color: #000000;\">}<\/span><\/pre>\n<p>\u70b9\u51fb\u201c\u9879\u76ee\u201d\u83dc\u5355\u4e2d\u7684\u201c\u4e0a\u4f20\u201d\u5c06\u56fa\u4ef6\u5237\u5199\u8fdb\u82af\u7247\uff0c\u5728 Arduino IDE \u4e0b\u65b9\u65e5\u5fd7\u7a97\u53e3\u770b\u5230 \u201c<span style=\"color: #ff6600;\">Connecting........____<\/span>\u201d \u65f6\uff0c\u6309\u4f4f\u5f00\u53d1\u677f\u7684\u201cBoot\u201d\u6309\u952e\uff08USB\u63a5\u53e3\u53f3\u8fb9\uff09\uff0c\u65e5\u5fd7\u51fa\u73b0\u201c<span style=\"color: #ff6600;\">Chip is ESP32D0WDQ6<\/span> \u201d \u540e\u5373\u53ef\u677e\u5f00\uff0c\u7b49\u5f85\u5237\u5199\u5b8c\u6210LED\u4eae\u8d77\u3002\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"width: 1920px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-457-1\" width=\"1920\" height=\"1080\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32led.mp4?_=1\" \/><a href=\"https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32led.mp4\">https:\/\/www.wxbit.com\/wp-content\/uploads\/2019\/05\/esp32led.mp4<\/a><\/video><\/div>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u4e00\u7bc7\uff0c\u6768\u8001\u5e08\u5c06\u8ddf\u5927\u5bb6\u5b66\u4e60\uff0c\u57fa\u4e8e App Inventor 2 WxBit \u6c49\u5316\u7248\u8bbe\u8ba1\u624b\u673a\u5e94\u7528\uff0c\u901a\u8fc7\u84dd\u7259 4.2 \u8fde\u63a5 ESP32 \u5f00\u53d1\u677f\uff0c\u8c03\u8282 LED \u706f\u7684\u989c\u8272\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ffffff;\">.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7cfb\u5217\u6559\u7a0b\uff0c\u6768\u8001\u5e08\u6307\u5bfc\u540c\u5b66\u4eec\u4ece\u96f6\u5f00\u59cb\u4e0a\u624b Arduino IDE\uff0c\u7136\u540e\u5b66\u4e60\u4f7f\u7528 App Inventor 2 WxBit\u00a0\u6c49\u5316\u7248\u4e0e\u5f00\u53d1\u677f\u4ea4\u4e92\u3002\u672c\u7bc7\u4e2d\u6211\u4eec\u5e76\u4e0d\u4f7f\u7528 Arduino\u00a0\u5f00\u53d1\u677f\uff0c\u53ea\u501f\u7528 Arduino\u00a0IDE \u6765\u7ed9\u6211\u4eec\u7684 ESP32\u00a0\u5f00\u53d1\u677f\u5199\u5165LED\u706f\u63a7\u5236\u56fa\u4ef6\u3002 <a href=\"https:\/\/www.wxbit.com\/?p=457\">\u9605\u8bfb\u5168\u6587 <i class=\"fa fa-share-square-o\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":512,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-457","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-appinventor"],"_links":{"self":[{"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=457"}],"version-history":[{"count":34,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/posts\/457\/revisions\/525"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=\/wp\/v2\/media\/512"}],"wp:attachment":[{"href":"https:\/\/www.wxbit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wxbit.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}