
{"id":1159,"date":"2016-11-17T10:49:27","date_gmt":"2016-11-17T02:49:27","guid":{"rendered":"https:\/\/www.webteach.tw\/?p=1159"},"modified":"2016-11-17T10:49:27","modified_gmt":"2016-11-17T02:49:27","slug":"arduino-%e8%97%8d%e8%8a%bd-%e5%9d%a6%e5%85%8b%e8%bb%8a-ps2%e6%90%96%e6%a1%bf-%e7%99%bc%e9%80%81%e7%ab%af-%e7%a8%8b%e5%bc%8f%e7%a2%bc","status":"publish","type":"post","link":"https:\/\/www.webteach.tw\/?p=1159","title":{"rendered":"[ Arduino ] &#8211; \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc"},"content":{"rendered":"<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div><div style=\"margin-top: 0px; margin-bottom: 0px;\" class=\"sharethis-inline-share-buttons\" ><\/div><p>\t\t\t\t[javascript]<br \/>\n#include  &lt;SoftwareSerial.h&gt;<br \/>\nSoftwareSerial BTSerial(10, 11); \/\/ RX | TX<br \/>\nint xpotPin = 14;  \/\/\u8bbe\u7f6e\u6a21\u62df\u53e30\u4e3aX\u7684\u4fe1\u53f7\u8f93\u5165\u7aef\u53e3<br \/>\nint ypotPin = 15;  \/\/\u8bbe\u7f6e\u6a21\u62df\u53e31\u4e3aY\u7684\u4fe1\u53f7\u8f93\u5165\u7aef\u53e3<br \/>\nint xval=0;<br \/>\nint yval=0;<br \/>\nvoid setup()<br \/>\n{<br \/>\n  Serial.begin(9600);<br \/>\n  Serial.println(&quot;Enter AT commands:&quot;);<br \/>\n  BTSerial.begin(9600);<br \/>\n  pinMode(xpotPin,INPUT);<br \/>\n  pinMode(ypotPin,INPUT);<br \/>\n}<br \/>\nvoid loop(){<br \/>\n \/\/ if (BTSerial.available())<br \/>\n \/\/   Serial.write(BTSerial.read());<br \/>\n \/\/ if (Serial.available())<br \/>\n \/\/   BTSerial.write(Serial.read());<br \/>\nint  x = analogRead(xpotPin);   \/\/xval\u53d8\u91cf\u4e3a\u4ece0\u4fe1\u53f7\u53e3\u8bfb\u53d6\u5230\u7684\u6570\u503c<br \/>\nint  y = analogRead(ypotPin);   \/\/yval\u53d8\u91cf\u4e3a\u4ece1\u4fe1\u53f7\u53e3\u8bfb\u53d6\u5230\u7684\u6570\u503c<br \/>\n Serial.println(&quot;x:&quot;);<br \/>\n Serial.println(x);<br \/>\n Serial.println(&quot;y:&quot;);<br \/>\n Serial.println(y);<br \/>\n \/\/ BTSerial.write(&#8216;s&#8217;);<br \/>\n \/\/ delay(2000);<br \/>\n \/\/ BTSerial.write(&#8216;s&#8217;);<br \/>\n if(x&gt;340 &amp;&amp; x &lt;350 &amp;&amp; y &gt;340 &amp;&amp; y&lt;346){BTSerial.write(&#8216;s&#8217;);}<br \/>\n if(y==0){BTSerial.write(&#8216;f&#8217;);  Serial.println(&quot;f&quot;);}\/\/\u524d<br \/>\n if(y&gt;670){BTSerial.write(&#8216;b&#8217;);}\/\/\u5f8c<br \/>\n if(x==0){BTSerial.write(&#8216;l&#8217;);}\/\/\u5de6<br \/>\n if(x&gt;680){BTSerial.write(&#8216;r&#8217;); Serial.println(&quot;r&quot;);}\/\/\u53f3<br \/>\n  delay(300);<br \/>\n}<br \/>\n[\/javascript]\t\t<\/p>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>[javascript] #includ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"categories":[19],"tags":[],"class_list":["post-1159","post","type-post","status-publish","format-standard","hentry","category-arduino"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webteach.tw\/?p=1159\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a\" \/>\n<meta property=\"og:description\" content=\"[javascript] #includ [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webteach.tw\/?p=1159\" \/>\n<meta property=\"og:site_name\" content=\"\u6df7\u6c34\u6478\u9b5a\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-17T02:49:27+00:00\" \/>\n<meta name=\"author\" content=\"jeff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"jeff\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159\"},\"author\":{\"name\":\"jeff\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/#\\\/schema\\\/person\\\/d434d754fd581338113eecfa923d7520\"},\"headline\":\"[ Arduino ] &#8211; \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc\",\"datePublished\":\"2016-11-17T02:49:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159\"},\"wordCount\":143,\"commentCount\":0,\"articleSection\":[\"Arduino\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.webteach.tw\\\/?p=1159#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159\",\"url\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159\",\"name\":\"[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/#website\"},\"datePublished\":\"2016-11-17T02:49:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/#\\\/schema\\\/person\\\/d434d754fd581338113eecfa923d7520\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webteach.tw\\\/?p=1159\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/?p=1159#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\\\/\\\/www.webteach.tw\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[ Arduino ] &#8211; \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/#website\",\"url\":\"https:\\\/\\\/www.webteach.tw\\\/\",\"name\":\"\u6df7\u6c34\u6478\u9b5a\",\"description\":\"\u5b78\u7121\u6b62\u5883,\u6559\u5b78\u76f8\u9577\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webteach.tw\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webteach.tw\\\/#\\\/schema\\\/person\\\/d434d754fd581338113eecfa923d7520\",\"name\":\"jeff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g\",\"caption\":\"jeff\"},\"sameAs\":[\"http:\\\/\\\/35.72.55.111\"],\"url\":\"https:\\\/\\\/www.webteach.tw\\\/?author=1\"},false]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webteach.tw\/?p=1159","og_locale":"zh_TW","og_type":"article","og_title":"[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a","og_description":"[javascript] #includ [&hellip;]","og_url":"https:\/\/www.webteach.tw\/?p=1159","og_site_name":"\u6df7\u6c34\u6478\u9b5a","article_published_time":"2016-11-17T02:49:27+00:00","author":"jeff","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005:":"jeff","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webteach.tw\/?p=1159#article","isPartOf":{"@id":"https:\/\/www.webteach.tw\/?p=1159"},"author":{"name":"jeff","@id":"https:\/\/www.webteach.tw\/#\/schema\/person\/d434d754fd581338113eecfa923d7520"},"headline":"[ Arduino ] &#8211; \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc","datePublished":"2016-11-17T02:49:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webteach.tw\/?p=1159"},"wordCount":143,"commentCount":0,"articleSection":["Arduino"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webteach.tw\/?p=1159#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webteach.tw\/?p=1159","url":"https:\/\/www.webteach.tw\/?p=1159","name":"[ Arduino ] - \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc - \u6df7\u6c34\u6478\u9b5a","isPartOf":{"@id":"https:\/\/www.webteach.tw\/#website"},"datePublished":"2016-11-17T02:49:27+00:00","author":{"@id":"https:\/\/www.webteach.tw\/#\/schema\/person\/d434d754fd581338113eecfa923d7520"},"breadcrumb":{"@id":"https:\/\/www.webteach.tw\/?p=1159#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webteach.tw\/?p=1159"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webteach.tw\/?p=1159#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/www.webteach.tw\/"},{"@type":"ListItem","position":2,"name":"[ Arduino ] &#8211; \u85cd\u82bd \u5766\u514b\u8eca -PS2\u6416\u687f \u767c\u9001\u7aef \u7a0b\u5f0f\u78bc"}]},{"@type":"WebSite","@id":"https:\/\/www.webteach.tw\/#website","url":"https:\/\/www.webteach.tw\/","name":"\u6df7\u6c34\u6478\u9b5a","description":"\u5b78\u7121\u6b62\u5883,\u6559\u5b78\u76f8\u9577","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webteach.tw\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Person","@id":"https:\/\/www.webteach.tw\/#\/schema\/person\/d434d754fd581338113eecfa923d7520","name":"jeff","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/secure.gravatar.com\/avatar\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5797200e421b670a2ce64d6e7382054c69b231d4aab55742c96bb1e51bc9fefc?s=96&d=mm&r=g","caption":"jeff"},"sameAs":["http:\/\/35.72.55.111"],"url":"https:\/\/www.webteach.tw\/?author=1"},false]}},"views":821,"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":0,"sum_votes":0},"_links":{"self":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/1159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1159"}],"version-history":[{"count":0,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/1159\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}