{"id":2045,"date":"2021-06-09T11:57:42","date_gmt":"2021-06-09T03:57:42","guid":{"rendered":"http:\/\/mgspace.wiki\/docs\/?post_type=docs&#038;p=2045"},"modified":"2021-06-09T16:55:46","modified_gmt":"2021-06-09T08:55:46","slug":"%e6%8c%89%e9%94%ae%e6%a8%a1%e5%9d%97","status":"publish","type":"docs","link":"http:\/\/mgspace.wiki\/docs\/?docs=%e6%8c%89%e9%94%ae%e6%a8%a1%e5%9d%97","title":{"rendered":"\u6309\u952e"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5b9e\u9a8c\u6750\u6599<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Uno R3\u5f00\u53d1\u677f<\/li><li>\u914d\u5957USB\u6570\u636e\u7ebf<\/li><li>\u9762\u5305\u677f\u53ca\u914d\u5957\u8fde\u63a5\u7ebf<\/li><li>1\u4e2aLED\u706f<\/li><li>1\u4e2a220\u03a9\u7535\u963b<\/li><li>1\u4e2a\u8f7b\u89e6\u6309\u952e<\/li><\/ul>\n\n\n\n<p>\u5b9e\u9a8c\u4e2d\u6211\u4eec\u7528\u5230\u4e86\u8f7b\u89e6\u6309\u952e\uff0c\u5e38\u89c1\u7684\u67092\u811a\u6309\u952e\u548c4\u811a\u6309\u952e\uff0c\u5176\u5185\u90e8\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"499\" src=\"http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/image-49.png\" alt=\"\" class=\"wp-image-2078\"\/><\/figure><\/div>\n\n\n\n<p>\u6309\u952e\u5185\u90e8\u7ed3\u6784<\/p>\n\n\n\n<p>\u5f53\u6309\u4e0b\u6309\u952e\u65f6\uff0c\u6309\u952e\u4e24\u7aef\u63a5\u901a\uff0c\u5f53\u653e\u5f00\u65f6\uff0c\u4e24\u7aef\u518d\u6b21\u65ad\u5f00\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u9a8c\u6b65\u9aa4<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>\u6839\u636e\u539f\u7406\u56fe\u642d\u5efa\u7535\u8def \u76f4\u63d2\u5f0fLED\u706f\u8d1f\u6781\u63a5\u5f00\u53d1\u677fGND\uff0c\u6b63\u6781\u63a5220\u03a9\u9650\u6d41\u7535\u963b\uff0c\u7535\u963b\u53e6\u4e00\u7aef\u63a5\u5f00\u53d1\u677f\u6570\u5b579\u5f15\u811a\u3002\u6309\u952e\u4e00\u7aef\u63a5\u5f00\u53d1\u677fGND\uff0c\u53e6\u4e00\u7aef\u63a5\u6570\u5b57\u5f15\u811a2\u3002 \u5b9e\u9a8c\u539f\u7406\u56fe\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/li><\/ol>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"403\" height=\"470\" src=\"http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/image-50.png\" alt=\"\" class=\"wp-image-2079\"\/><\/figure><\/div>\n\n\n\n<ol class=\"wp-block-list\"><li>\u65b0\u5efasketch\uff0c\u62f7\u8d1d\u5982\u4e0b\u4ee3\u7801\u66ff\u6362\u81ea\u52a8\u751f\u6210\u7684\u4ee3\u7801\u5e76\u8fdb\u884c\u4fdd\u5b58\u3002<\/li><\/ol>\n\n\n\n<p><em><\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n * Digital_Button\n * \u901a\u8fc7\u6309\u952e\u63a7\u5236LED\u706f\u4eae\u706d\n *\/\n\nint buttonPin = 2;     \/\/ \u6309\u952e\u7684\u7ba1\u811a\u5b9a\u4e49\nint ledPin =  9;      \/\/ LED\u706f\u7ba1\u811a\u5b9a\u4e49\n\nvoid setup() {\n  pinMode(ledPin, OUTPUT);  \/\/\u8bbe\u7f6eLED\u7ba1\u811a\u8f93\u51fa\u6a21\u5f0f\n  pinMode(buttonPin, INPUT_PULLUP); \/\/\u8bbe\u7f6e\u6309\u952e\u7ba1\u811a\u4e0a\u62c9\u8f93\u5165\u6a21\u5f0f\n}\n\nvoid loop() {\n  if (digitalRead(buttonPin) == LOW) { \/\/ \u82e5\u6309\u952e\u88ab\u6309\u4e0b\n    delay(80); \/\/\u7b49\u5f85\u8df3\u8fc7\u6309\u952e\u6296\u52a8\u7684\u4e0d\u7a33\u5b9a\u8fc7\u7a0b\n    if (digitalRead(buttonPin) == LOW) \/\/ \u82e5\u6309\u952e\u88ab\u6309\u4e0b\n    {      \n      digitalWrite(ledPin, HIGH); \/\/ \u70b9\u4eaeLED\u706f\n    }\n  }\n  else {   \n    digitalWrite(ledPin, LOW); \/\/ \u7184\u706dLED\u706f\n  }\n\n}\n<\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>\u8fde\u63a5\u5f00\u53d1\u677f\uff0c\u8bbe\u7f6e\u597d\u5bf9\u5e94\u7aef\u53e3\u53f7\u548c\u5f00\u53d1\u677f\u7c7b\u578b\uff0c\u8fdb\u884c\u7a0b\u5e8f\u4e0b\u8f7d\u3002<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"613\" src=\"http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/image-51.png\" alt=\"\" class=\"wp-image-2080\" srcset=\"http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/image-51.png 670w, http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/image-51-500x457.png 500w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>\u7a0b\u5e8f\u4e0b\u8f7d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u9a8c\u73b0\u8c61<\/h2>\n\n\n\n<p>\u6309\u4e0b\u6309\u952e\uff0cLED\u706f\u70b9\u4eae\u3002\u653e\u5f00\u6309\u952e\uff0cLED\u706f\u7184\u706d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"280\" height=\"210\" src=\"http:\/\/mgspace.wiki\/docs\/wp-content\/uploads\/2021\/06\/1437476-6ec5bfbc798086ee.gif\" alt=\"\" class=\"wp-image-2081\"\/><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5b9e\u9a8c\u73b0\u8c61<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u51fd\u6570\u4ecb\u7ecd<\/h2>\n\n\n\n<p><strong>digitalRead()<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u63cf\u8ff0\uff1a\u8bfb\u53d6\u6307\u5b9a\u6570\u5b57\u5f15\u811a\u7684\u503c<\/li><li>\u51fd\u6570\u539f\u578b\uff1a<strong>digitalRead(pin)<\/strong><\/li><li>\u53c2\u6570\uff1a\u8981\u8bfb\u53d6\u7684\u6570\u5b57\u5f15\u811a\u7f16\u53f7<\/li><li>\u8fd4\u56de\u503c\uff1aHIGH(1)\u6216LOW(0)<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3\u5206\u6790<\/h2>\n\n\n\n<p>\u901a\u8fc7digitalRead()\u51fd\u6570\u6765\u8bfb\u53d6\u6570\u5b57I\/O\u5f15\u811a\u72b6\u6001\uff0c\u7136\u540e\u6839\u636e\u72b6\u6001\u53bb\u70b9\u4eae\u6216\u8005\u7184\u706dLED\u706f\u3002\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u7531\u4e8eArduino\u4e0a\u7535\u540e\uff0c\u6570\u5b57I\/O\u7ba1\u811a\u5904\u4e8e\u60ac\u7a7a\u72b6\u6001\uff0c\u6b64\u65f6\u901a\u8fc7digitalRead()\u8bfb\u5230\u7684\u662f\u4e00\u4e2a\u4e0d\u7a33\u5b9a\u7684\u503c(\u53ef\u80fd\u662f\u9ad8\uff0c\u4e5f\u53ef\u80fd\u662f\u4f4e)\u3002\u6240\u4ee5\u901a\u8fc7pinMode()\u51fd\u6570\u8bbe\u7f6e\u6309\u952e\u5f15\u811a\u4e3a\u4e0a\u62c9\u8f93\u5165\u6a21\u5f0f\u3002\u5373\u4f7f\u7528\u5185\u90e8\u4e0a\u62c9\u7535\u963b\uff0c\u6309\u952e\u672a\u6309\u4e0b\u65f6\uff0c\u5f15\u811a\u5c06\u4e3a\u9ad8\u7535\u5e73\uff0c\u6309\u952e\u6309\u4e0b\u4e3a\u4f4e\u7535\u5e73\u3002<\/li><li>\u6309\u952e\u5728\u6309\u4e0b\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6709\u4e00\u6bb5\u63a5\u89e6\u672a\u63a5\u89e6\u7684\u4e0d\u7a33\u5b9a\u8fc7\u7a0b\uff0c\u5373\u6309\u952e\u7684\u6296\u52a8\u3002\u5728\u5224\u65ad\u6309\u952e\u72b6\u6001\u65f6\uff0c\u901a\u8fc7delay()\u5ef6\u65f6\u8df3\u8fc7\u6296\u52a8\u7684\u4e0d\u7a33\u5b9a\u72b6\u6001\uff0c\u5373\u8f6f\u4ef6\u4e0a\u8fdb\u884c\u6d88\u6296\u3002<\/li><li>\u53ef\u4ee5\u4e0d\u4f7f\u7528\u5185\u90e8\u4e0a\u62c9\u7535\u963b\uff0c\u5728\u7535\u8def\u4e0a\u6dfb\u52a0\u6309\u952e\u7684\u4e0a\u62c9\u7535\u963b\u6216\u4e0b\u62c9\u7535\u963b\uff0c\u53ef\u8fbe\u5230\u76f8\u540c\u6548\u679c\u3002<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u9a8c\u6750\u6599 Uno R3\u5f00\u53d1\u677f \u914d\u5957USB\u6570\u636e\u7ebf \u9762\u5305\u677f\u53ca\u914d\u5957\u8fde\u63a5\u7ebf 1\u4e2aLED\u706f 1\u4e2a220\u03a9\u7535\u963b 1\u4e2a\u8f7b\u89e6\u6309 &hellip; <a href=\"http:\/\/mgspace.wiki\/docs\/?docs=%e6%8c%89%e9%94%ae%e6%a8%a1%e5%9d%97\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u6309\u952e\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[33],"doc_tag":[],"class_list":["post-2045","docs","type-docs","status-publish","hentry","doc_category-electronic"],"_links":{"self":[{"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/docs\/2045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2045"}],"version-history":[{"count":3,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/docs\/2045\/revisions"}],"predecessor-version":[{"id":2083,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=\/wp\/v2\/docs\/2045\/revisions\/2083"}],"wp:attachment":[{"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2045"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_category&post=2045"},{"taxonomy":"doc_tag","embeddable":true,"href":"http:\/\/mgspace.wiki\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=2045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}