{"id":802,"date":"2017-06-03T22:01:55","date_gmt":"2017-06-03T14:01:55","guid":{"rendered":"http:\/\/192.168.1.20\/?p=802"},"modified":"2017-06-03T22:01:55","modified_gmt":"2017-06-03T14:01:55","slug":"arduino-{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}e4{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}b8{47dd41ec6bdcbd9a214c783a3735392b82ea6d1d918378c5a53e064","status":"publish","type":"post","link":"http:\/\/alextop.top\/?p=802","title":{"rendered":"Arduino &#8211; \u4e32\u53e3\u64cd\u4f5c\u51fd\u6570\u4e0e\u793a\u4f8b\u4ee3\u7801\u5927\u5168"},"content":{"rendered":"<p style=\"text-align: center; background: white\"><span style=\"color:#333333; font-size:24pt\"><strong><span style=\"font-family:Arial\">Arduino &#8211; <\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u64cd\u4f5c\u51fd\u6570\u4e0e\u793a\u4f8b\u4ee3\u7801\u5927\u5168<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino1.png\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\">\n\u00a0<\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u672c\u6587\u603b\u7ed3\u4e86<\/span><span style=\"font-family:Arial\">Arduino<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5e38\u7528\u4e32\u53e3\u64cd\u4f5c\u51fd\u6570\uff0c\u51fd\u6570\u8bf4\u660e\u90e8\u5206\u6765\u6e90\u4e8e<a href=\"https:\/\/www.arduino.cc\/en\/Reference\/Serial\" target=\"_blank\"\/><\/span><span style=\"color:#336699\"><span style=\"font-family:Arial; text-decoration:underline\">Arduino <\/span><span style=\"font-family:\u5b8b\u4f53\"><span style=\"text-decoration:underline\">\u5b98\u7f51\u4e32\u53e3\u4f7f\u7528\u6307\u5357<\/span><span style=\"color:#333333\">\uff0c\u793a\u4f8b\u4e0e\u5b9e\u9a8c\u90e8\u5206\u4e3a\u81ea\u7f16\u3002\u672c\u6587\u662f\u5bf9<\/span><\/span><span style=\"font-family:Arial\">Arduino<\/span><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u64cd\u4f5c\u51fd\u6570\u7684\u8f83\u5168\u9762\u603b\u7ed3\uff0c\u53ef\u4f5c\u4e3a\u5de5\u5177\u8d34\u67e5\u627e\u4f7f\u7528\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t1\"\/>1.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u8bbe\u7f6e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t2\"\/>Serial.begin();\u00a0\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t3\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5f00\u542f\u4e32\u53e3\uff0c\u901a\u5e38\u7f6e\u4e8e<\/span><span style=\"font-family:Arial\">setup()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u51fd\u6570\u4e2d\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t4\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.begin(speed);\u00a0\u00a0<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.begin(speed,config); \u00a0<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t5\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">speed: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6ce2\u7279\u7387\uff0c\u4e00\u822c\u53d6\u503c<\/span><span style=\"font-family:Arial\">300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600,115200<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">config: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bbe\u7f6e\u6570\u636e\u4f4d\u3001\u6821\u9a8c\u4f4d\u548c\u505c\u6b62\u4f4d\u3002\u4f8b\u5982<\/span><span style=\"font-family:Arial\">Serial.begin(speed,Serial_8N1); \u00a0Serial_8N1<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e2d\uff1a<\/span><span style=\"font-family:Arial\">8<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8868\u793a<\/span><span style=\"font-family:Arial\">8<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e2a\u6570\u636e\u4f4d\uff0c<\/span><span style=\"font-family:Arial\">N<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8868\u793a\u6ca1\u6709\u6821\u9a8c\uff0c<\/span><span style=\"font-family:Arial\">1<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8868\u793a\u6709<\/span><span style=\"font-family:Arial\">1<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e2a\u505c\u6b62\u4f4d\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t6\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t7\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">Serial.begin(9600);\u00a0<span style=\"color:#008200\">\/\/\u00a0opensserial\u00a0port,\u00a0sets\u00a0data\u00a0rate\u00a0to\u00a09600\u00a0bps\u00a0<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t9\"\/>Serial.end();\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t10\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u7981\u6b62\u4e32\u53e3\u4f20\u8f93\u51fd\u6570\u3002\u6b64\u65f6\u4e32\u53e3\u4f20\u8f93\u7684<\/span><span style=\"font-family:Arial\">pin<\/span><span style=\"font-family:\u5b8b\u4f53\">\u811a\u53ef\u4ee5\u4f5c\u4e3a\u6570\u5b57<\/span><span style=\"font-family:Arial\">IO<\/span><span style=\"font-family:\u5b8b\u4f53\">\u811a\u4f7f\u7528\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t11\"\/>\u8bed\u6cd5<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.end()<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t12\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t13\"\/>\u8fd4\u56de<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t14\"\/>2.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u6e05\u7a7a\u4e32\u53e3\u7f13\u5b58<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t15\"\/>Serial.flush();\u00a0\u00a0\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t16\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">1.0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7248\u672c\u4e4b\u524d\u4e3a\u6e05\u7a7a\u4e32\u53e3\u7f13\u5b58\uff0c\u73b0\u5728\u8be5\u51fd\u6570\u4f5c\u7528\u4e3a\u7b49\u5f85\u8f93\u51fa\u6570\u636e\u4f20\u9001\u5b8c\u6bd5\u3002\u5982\u679c\u8981\u6e05\u7a7a\u4e32\u53e3\u7f13\u5b58\u7684\u8bdd\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/span><span style=\"font-family:Arial\">while(Serial.read() &gt;= 0)<\/span><span style=\"font-family:\u5b8b\u4f53\">\u6765\u4ee3\u66ff\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t17\"\/>\u8bed\u6cd5<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.flush ()<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t18\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t19\"\/>\u8fd4\u56de<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t20\"\/>while(Serial.read()&gt;= 0){}<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t21\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u56e0<\/span><span style=\"font-family:Arial\">Serial.read()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u51fd\u6570\u8bfb\u53d6\u4e32\u53e3\u7f13\u5b58\u4e2d\u7684\u4e00\u4e2a\u5b57\u7b26\uff0c\u5e76\u5220\u9664\u5df2\u8bfb\u5b57\u7b26\u3002\u56e0\u6b64\u53ef\u4ee5\u7528\u8fd9\u53e5\u4ee3\u7801\u6765\u6e05\u7a7a\u4e32\u53e3\u7f13\u5b58\u3002\u5b9e\u9a8c\u4ee3\u7801\u8be6\u89c1\u4e0b\u6587\u4ee3\u7801\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:13pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t22\"\/>\u8bed\u6cd5<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">while(Serial.read() &gt;=0){}<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t23\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t24\"\/>\u8fd4\u56de<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t25\"\/>3.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa\u4e32\u53e3\u6570\u636e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5c06\u6253\u5370\u8f93\u51fa\u4e32\u53e3\u6570\u636e\u7684\u51fd\u6570\u5728\u8fd9\u4e00\u5c0f\u8282\u7ed9\u51fa\uff0c\u65b9\u4fbf\u5927\u5bb6\u9605\u8bfb\u540e\u9762\u7684\u5404\u4e2a\u793a\u4f8b\u4ee3\u7801\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t26\"\/>Serial.print();\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t27\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u8f93\u51fa\u6570\u636e\u51fd\u6570\uff0c\u5199\u5165\u5b57\u7b26\u4e32\u6570\u636e\u5230\u4e32\u53e3\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t28\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.print(val)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.print(val,format)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t29\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">val: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6253\u5370\u7684\u503c\uff0c\u4efb\u610f\u6570\u636e\u7c7b\u578b<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">format: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa\u7684\u6570\u636e\u683c\u5f0f\uff0c\u5305\u62ec\u6574\u6570\u7c7b\u578b\u548c\u6d6e\u70b9\u578b\u6570\u636e\u7684\u5c0f\u6570\u70b9\u4f4d\u6570\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t30\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<ul>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(78, BIN) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;1001110&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(78, OCT) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;116&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(78, DEC) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;78&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(78, HEX) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;4E&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(1.23456, 0) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;1&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(1.23456, 2) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;1.23&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(1.23456, 4) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;1.2346&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(&#8216;N&#8217;) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;N&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">Serial.print(&#8220;Hello world.&#8221;) <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f97\u5230<\/span><span style=\"font-family:Arial\"> &#8220;Hello world.&#8221;<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t31\"\/>Serial.println();<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t32\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5199\u5165\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u5e76\u6362\u884c\u3002\u5b9e\u9a8c\u4ee3\u7801\u8be6\u89c1\u4e0b\u6587\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t33\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.println(val)\u00a0<br \/>Serial.println(val,format)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t34\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">val: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6253\u5370\u7684\u503c\uff0c\u4efb\u610f\u6570\u636e\u7c7b\u578b<\/span><span style=\"font-family:Arial\">\u00a0<br \/>format: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa\u7684\u6570\u636e\u683c\u5f0f\uff0c\u5305\u62ec\u6574\u6570\u7c7b\u578b\u548c\u6d6e\u70b9\u578b\u6570\u636e\u7684\u5c0f\u6570\u70b9\u4f4d\u6570\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t35\"\/>\u8fd4\u56de<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5b57\u8282<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t36\"\/>Serial.SerialEvent();<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u6570\u636e\u51c6\u5907\u597d\u65f6\u89e6\u53d1\u7684\u4e8b\u4ef6\u51fd\u6570\uff0c\u5373\u4e32\u53e3\u6570\u636e\u51c6\u5907\u597d\u8c03\u7528\u8be5\u51fd\u6570\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t37\"\/>\u8bed\u6cd5<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.serialEvent{\/\/statements}<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t38\"\/>\u53c2\u6570<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">statements: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u4efb\u4f55\u6709\u6548\u7684\u8bed\u53e5\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t39\"\/>4.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bfb\u4e32\u53e3\u7f13\u5b58\u533a\u6570\u636e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t40\"\/>Serial.available();<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t41\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5224\u65ad\u4e32\u53e3\u7f13\u51b2\u5668\u7684\u72b6\u6001\u51fd\u6570\uff0c\u7528\u4ee5\u5224\u65ad\u6570\u636e\u662f\u5426\u9001\u8fbe\u4e32\u53e3\u3002\u6ce8\u610f\u4f7f\u7528\u65f6\u901a\u5e38\u7528<\/span><span style=\"font-family:Arial\">delay(100)<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4ee5\u4fdd\u8bc1\u4e32\u53e3\u5b57\u7b26\u63a5\u6536\u5b8c\u6bd5\uff0c\u5373\u4fdd\u8bc1<\/span><span style=\"font-family:Arial\">Serial.available()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u7684\u662f\u7f13\u51b2\u533a\u51c6\u786e\u7684\u53ef\u8bfb\u5b57\u8282\u6570\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t42\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.available();<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t43\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t44\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u7f13\u51b2\u533a\u53ef\u8bfb\u5b57\u8282\u6570\u76ee<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t45\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">\u00a0(Serial.available()\u00a0&gt;\u00a00)\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-size:9pt\"><span style=\"font-family:Consolas\">\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0<span style=\"color:#008200\">\/\/\u00a0<\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u7b49\u5f85\u6570\u636e\u4f20\u5b8c<\/span><span style=\"font-family:Consolas\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:seagreen\"><strong>int<\/strong><span style=\"color:black\">\u00a0numdata\u00a0=\u00a0Serial.available();\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.available\u00a0=\u00a0:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.println(numdata);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-size:9pt\"><span style=\"font-family:Consolas\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=0){}\u00a0<span style=\"color:#008200\">\/\/<\/span><\/span><\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u6e05\u7a7a\u4e32\u53e3\u7f13\u5b58<\/span><span style=\"font-family:Consolas\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t47\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino2.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t48\"\/>Serial.read();<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t49\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8bfb\u53d6\u4e32\u53e3\u6570\u636e\uff0c\u4e00\u6b21\u8bfb\u4e00\u4e2a\u5b57\u7b26\uff0c\u8bfb\u5b8c\u540e\u5220\u9664\u5df2\u8bfb\u6570\u636e\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t50\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.read();<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t51\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t52\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u4e32\u53e3\u7f13\u5b58\u4e2d\u7b2c\u4e00\u4e2a\u53ef\u8bfb\u5b57\u8282\uff0c\u5f53\u6ca1\u6709\u53ef\u8bfb\u6570\u636e\u65f6\u8fd4\u56de<\/span><span style=\"font-family:Arial\">-1<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u6574\u6570\u7c7b\u578b\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t53\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0comchar;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}\/\u00a0\/clear\u00a0serialbuffer\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-size:9pt\"><span style=\"font-family:Consolas\">\u00a0\u00a0\u00a0\u00a0comchar\u00a0=\u00a0Serial.read();<span style=\"color:#008200\">\/\/<\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bfb\u4e32\u53e3\u7b2c\u4e00\u4e2a\u5b57\u8282<\/span><span style=\"font-family:Consolas\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.read:\u00a0&#8220;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.println(comchar);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t54\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino3.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u5b9e\u9a8c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/span><span style=\"font-family:Arial\">Serial.read()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u6bcf\u6b21\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u5b57\u7b26\uff0c\u5e76\u5c06\u8bfb\u8fc7\u7684\u5b57\u7b26\u5220\u9664\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t55\"\/>Serial.peek();\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t56\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8bfb\u4e32\u53e3\u7f13\u5b58\u4e2d\u4e0b\u4e00\u5b57\u8282\u7684\u6570\u636e\uff08\u5b57\u7b26\u578b\uff09\uff0c\u4f46\u4e0d\u4ece\u5185\u90e8\u7f13\u5b58\u4e2d\u5220\u9664\u8be5\u6570\u636e\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fde\u7eed\u7684\u8c03\u7528<\/span><span style=\"font-family:Arial\">peek()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5c06\u8fd4\u56de\u540c\u4e00\u4e2a\u5b57\u7b26\u3002\u800c\u8c03\u7528<\/span><span style=\"font-family:Arial\">read()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5219\u4f1a\u8fd4\u56de\u4e0b\u4e00\u4e2a\u5b57\u7b26\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t57\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.peek();<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t58\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t59\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u4e32\u53e3\u7f13\u5b58\u4e2d\u4e0b\u4e00\u5b57\u8282\uff08\u5b57\u7b26\uff09\u7684\u6570\u636e\uff0c\u5982\u679c\u6ca1\u6709\u8fd4\u56de<\/span><span style=\"font-family:Arial\">-1<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u6574\u6570<\/span><span style=\"font-family:Arial\">int<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t60\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0comchar;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0comchar\u00a0=\u00a0Serial.peek();\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.peek:\u00a0&#8220;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0Serial.println(comchar);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t61\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino4.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u5b9e\u9a8c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/span><span style=\"font-family:Arial\">Serial.peek()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u6bcf\u6b21\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6\u4e00\u4e2a\u5b57\u7b26\uff0c\u5e76\u4e0d\u4f1a\u5c06\u8bfb\u8fc7\u7684\u5b57\u7b26\u5220\u9664\u3002\u7b2c\u4e8c\u6b21\u8bfb\u53d6\u65f6\u4ecd\u7136\u4e3a\u540c\u4e00\u4e2a\u5b57\u7b26\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t62\"\/>Serial.readBytes(buffer,length);<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t63\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u8bfb\u53d6\u6307\u5b9a\u957f\u5ea6<\/span><span style=\"font-family:Arial\">length<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u5b57\u7b26\u5230\u7f13\u5b58\u6570\u7ec4<\/span><span style=\"font-family:Arial\">buffer<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t64\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.readBytes(buffer,length);<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t65\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">buffer: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u7f13\u5b58\u53d8\u91cf<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">length:<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bbe\u5b9a\u7684\u8bfb\u53d6\u957f\u5ea6<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t66\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u5b58\u5165\u7f13\u5b58\u7684\u5b57\u7b26\u6570\uff0c<\/span><span style=\"font-family:Arial\">0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8868\u793a\u6ca1\u6709\u6709\u6548\u6570\u636e\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t67\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0buffer[18];\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>int<\/strong><span style=\"color:black\">\u00a0numdata=0;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0numdata\u00a0=\u00a0Serial.readBytes(buffer,3);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.readBytes:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(buffer);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>for<\/strong><span style=\"color:black\">(<span style=\"color:seagreen\"><strong>int<\/strong><span style=\"color:black\">\u00a0i=0;\u00a0i&lt;18;\u00a0i++){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0buffer[i]=<span style=\"color:blue\">&#8216;\\0&#8217;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t68\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino5.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino6.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\">\n\u00a0<\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u8bfb\u53d6\u6307\u5b9a\u957f\u5ea6\u4e3a<\/span><span style=\"font-family:Arial\">3<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u5b57\u8282\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t69\"\/>Serial.readBytesUntil(character,buffer,length);<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t70\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u8bfb\u53d6\u6307\u5b9a\u957f\u5ea6\u7684\u5b57\u7b26\u5230\u6570\u7ec4<\/span><span style=\"font-family:Arial\">buffer<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u9047\u5230\u7ec8\u6b62\u5b57\u7b26<\/span><span style=\"font-family:Arial\">character<\/span><span style=\"font-family:\u5b8b\u4f53\">\u540e\u505c\u6b62\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t71\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.readBytesUntil(character ,buffer,length);<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t72\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">character : <\/span><span style=\"font-family:\u5b8b\u4f53\">\u67e5\u627e\u7684\u5b57\u7b26<\/span><span style=\"font-family:Arial\"> (char)<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">buffer: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5b58\u50a8\u8bfb\u53d6\u6570\u636e\u7684\u7f13\u5b58<\/span><span style=\"font-family:Arial\">(char[] <\/span><span style=\"font-family:\u5b8b\u4f53\">\u6216<\/span><span style=\"font-family:Arial\">byte[])<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">length:<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bbe\u5b9a\u7684\u8bfb\u53d6\u957f\u5ea6<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t73\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u5b58\u5165\u7f13\u5b58\u7684\u5b57\u7b26\u6570\uff0c<\/span><span style=\"font-family:Arial\">0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8868\u793a\u6ca1\u6709\u6709\u6548\u6570\u636e\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t74\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0buffer[18];\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:seagreen; font-size:9pt\"><span style=\"font-family:Consolas\"><strong>char<\/strong><span style=\"color:black\">\u00a0character\u00a0=\u00a0<span style=\"color:blue\">&#8216;,&#8217;<span style=\"color:black\">;\u00a0<span style=\"color:#008200\">\/\/<\/span><\/span><\/span><\/span><\/span><span style=\"font-family:\u5b8b\u4f53\">\u7ec8\u6b62\u5b57\u7b26<\/span><span style=\"color:black; font-family:Consolas\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>int<\/strong><span style=\"color:black\">\u00a0numdata=0;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialport<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0numdata\u00a0=Serial.readBytesUntil(character,buffer,3);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.readBytes:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(buffer);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>for<\/strong><span style=\"color:black\">(<span style=\"color:seagreen\"><strong>int<\/strong><span style=\"color:black\">\u00a0i=0;\u00a0i&lt;18;\u00a0i++){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0buffer[i]=<span style=\"color:blue\">&#8216;\\0&#8217;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t75\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino7.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#4f4e4e\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6<\/span><span style=\"font-family:Arial\">3<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e2a\u5b57\u7b26\uff0c\u5f53\u9047\u5230<\/span><span style=\"color:#333333\"><span style=\"font-family:Arial\">&#8220;,&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u65f6\u7ec8\u6b62\u8bfb\u53d6\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-size:13pt\"><strong><span style=\"font-family:Arial\"><a name=\"t76\"\/>Serial.readString()<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff1b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t77\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u8bfb\u53d6\u5168\u90e8\u6570\u636e\u5230\u4e00\u4e2a\u5b57\u7b26\u4e32\u578b\u53d8\u91cf\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t78\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.readString();<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t79\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">None<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t80\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u4e2d\u8bfb\u53d6\u7684\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t81\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">String\u00a0comdata\u00a0=\u00a0<span style=\"color:blue\">&#8220;&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}\u00a0<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0comdata\u00a0=\u00a0Serial.readString();\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.readString:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(comdata);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0comdata\u00a0=\u00a0<span style=\"color:blue\">&#8220;&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t82\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino8.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u5b9e\u9a8c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/span><span style=\"font-family:Arial\">Serial.readString()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6\u5b57\u7b26\u81f3\u5b57\u7b26\u4e32\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-size:13pt\"><strong><span style=\"font-family:Arial\"><a name=\"t83\"\/>Serial.readStringUntil()<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff1b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t84\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u8bfb\u53d6\u5b57\u7b26\u5230\u4e00\u4e2a\u5b57\u7b26\u4e32\u578b\u53d8\u91cf\uff0c\u76f4\u81f3\u8bfb\u5b8c\u6216\u9047\u5230\u67d0\u7ec8\u6b62\u5b57\u7b26\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t85\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.readStringUntil(terminator)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t86\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">terminator:<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7ec8\u6b62\u5b57\u7b26<\/span><span style=\"font-family:Arial\">(cha<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b<\/span><span style=\"font-family:Arial\">)<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t87\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u4e2d\u8bfb\u53d6\u7684\u6574\u4e2a\u5b57\u7b26\u4e32\uff0c\u76f4\u81f3\u68c0\u6d4b\u5230\u7ec8\u6b62\u5b57\u7b26\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t88\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">String\u00a0comdata\u00a0=\u00a0<span style=\"color:blue\">&#8220;&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0terminator\u00a0=\u00a0<span style=\"color:blue\">&#8216;,&#8217;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}\u00a0<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0comdata\u00a0=Serial.readStringUntil(terminator);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.readStringUntil:\u00a0&#8220;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(comdata);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t89\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino9.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u8bfb\u53d6\u6240\u6709\u5b57\u7b26\u5b58\u653e\u4e8e\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">comdata<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u76f4\u81f3\u9047\u5230\u5b57\u7b26<\/span><span style=\"font-family:Arial\">&#8220;,&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u65f6\u7ec8\u6b62\u8bfb\u53d6\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t90\"\/>Serial.parseFloat();<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t91\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8bfb\u4e32\u53e3\u7f13\u5b58\u533a\u7b2c\u4e00\u4e2a\u6709\u6548\u7684\u6d6e\u70b9\u578b\u6570\u636e\uff0c\u6570\u5b57\u5c06\u88ab\u8df3\u8fc7\u3002\u5f53\u8bfb\u5230\u7b2c\u4e00\u4e2a\u975e\u6d6e\u70b9\u6570\u65f6\u51fd\u6570\u7ed3\u675f\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t92\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.parseFloat()<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t93\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#4f4e4e; font-family:Arial\">None<span style=\"color:#333333\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t94\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u4e32\u53e3\u7f13\u5b58\u533a\u7b2c\u4e00\u4e2a\u6709\u6548\u7684\u6d6e\u70b9\u578b\u6570\u636e\uff0c\u6570\u5b57\u5c06\u88ab\u8df3\u8fc7\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t95\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>float<\/strong><span style=\"color:black\">\u00a0comfloat;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0comfloat\u00a0=\u00a0Serial.parseFloat();\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.parseFloat:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(comfloat);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t96\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino10.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u5b9e\u9a8c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/span><span style=\"font-family:Arial\">Serial. parseFloat()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u6709\u6548\u7684\u6d6e\u70b9\u6570\uff0c\u7b2c\u4e00\u4e2a\u6709\u6548\u6570\u5b57\u4e4b\u524d\u7684\u8d1f\u53f7\u4e5f\u5c06\u88ab\u8bfb\u53d6\uff0c\u72ec\u7acb\u7684\u8d1f\u53f7\u5c06\u88ab\u820d\u5f03\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t97\"\/>Serial.parseInt()<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t98\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u63a5\u6536\u6570\u636e\u6d41\u4e2d\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u6709\u6548\u6574\u6570\uff08\u5305\u62ec\u8d1f\u6570\uff09\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u6ce8\u610f\uff1a<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<ul>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u975e\u6570\u5b57\u7684\u9996\u5b57\u7b26\u6216\u8005\u8d1f\u53f7\u5c06\u88ab\u8df3\u8fc7<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5f53\u53ef\u914d\u7f6e\u7684\u8d85\u65f6\u503c\u6ca1\u6709\u8bfb\u5230\u6709\u6548\u5b57\u7b26\u65f6\uff0c\u6216\u8005\u8bfb\u4e0d\u5230\u6709\u6548\u6574\u6570\u65f6\uff0c\u5206\u6790\u505c\u6b62<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5982\u679c\u8d85\u65f6\u4e14\u8bfb\u4e0d\u5230\u6709\u6548\u6574\u6570\u65f6\uff0c\u8fd4\u56de<\/span><span style=\"font-family:Arial\">0<br \/>\n<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t99\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.parseInt()<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.parseInt(charskipChar)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t100\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">skipChar<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7528\u4e8e\u5728\u641c\u7d22\u4e2d\u8df3\u8fc7\u6307\u5b9a\u5b57\u7b26\uff08\u6b64\u7528\u6cd5\u672a\u77e5\uff09<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t101\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd4\u56de\u4e0b\u4e00\u4e2a\u6709\u6548\u6574\u578b\u503c\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t102\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>int<\/strong><span style=\"color:black\">\u00a0comInt;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">voidsetup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0comInt\u00a0=\u00a0Serial.parseInt();\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;Serial.parseInt:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(comInt);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t103\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino11.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u5b9e\u9a8c\u7ed3\u679c\u53ef\u4ee5\u770b\u51fa\uff1a<\/span><span style=\"font-family:Arial\">Serial. parseInt()<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u4e2d\u8bfb\u53d6\u7b2c\u4e00\u4e2a\u6709\u6548\u6574\u6570\uff0c\u7b2c\u4e00\u4e2a\u6709\u6548\u6570\u5b57\u4e4b\u524d\u7684\u8d1f\u53f7\u4e5f\u5c06\u88ab\u8bfb\u53d6\uff0c\u72ec\u7acb\u7684\u8d1f\u53f7\u5c06\u88ab\u820d\u5f03\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t104\"\/>5.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u67e5\u627e\u6307\u5b9a\u5b57\u7b26\u4e32<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t105\"\/>Serial.find()<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t106\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u8bfb\u53d6\u6570\u636e\uff0c\u5bfb\u627e\u76ee\u6807\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">target(char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b<\/span><span style=\"font-family:Arial\">)<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t107\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">char target[] = &#8220;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u76ee\u6807\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">&#8220;;<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.find(target);\u00a0<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t108\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">target: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u76ee\u6807\u5b57\u7b26\u4e32\uff08<\/span><span style=\"font-family:Arial\">char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b\uff09<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t109\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u627e\u5230\u76ee\u6807\u5b57\u7b26\u4e32\u8fd4\u56de\u771f\uff0c\u5426\u5219\u4e3a\u5047<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t110\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0target[]\u00a0=<span style=\"color:blue\">&#8220;test&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(\u00a0Serial.find(target)){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;find\u00a0traget:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(target);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t111\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><span style=\"color:#333333; font-family:Arial\"><br \/><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino12.jpg\" alt=\"\"\/><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u8f93\u5165\u5b57\u7b26\u4e2d\u53ea\u8981\u6709<\/span><span style=\"font-family:Arial\">test,<\/span><span style=\"font-family:\u5b8b\u4f53\">\u51fd\u6570\u8fd4\u56de\u771f\uff0c\u6253\u5370\u51fa\u76ee\u6807\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">&#8220;test&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u5426\u5219\u8fd4\u56de\u5047\uff0c\u4e0d\u6253\u5370\u4efb\u4f55\u503c\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t112\"\/>Serial.findUntil(target,terminal);\u00a0\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t113\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4ece\u4e32\u53e3\u7f13\u5b58\u533a\u8bfb\u53d6\u6570\u636e\uff0c\u5bfb\u627e\u76ee\u6807\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">target(char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b\u6570\u7ec4<\/span><span style=\"font-family:Arial\">)<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u76f4\u5230\u51fa\u73b0\u7ed9\u5b9a\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">terminal(char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b<\/span><span style=\"font-family:Arial\">)<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u627e\u5230\u4e3a\u771f\uff0c\u5426\u5219\u4e3a\u5047\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t114\"\/>\u8bed\u6cd5<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.findUntil(target,terminal);\u00a0<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t115\"\/>\u53c2\u6570<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">target\u00a0: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u76ee\u6807\u5b57\u7b26\u4e32\uff08<\/span><span style=\"font-family:Arial\">char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b\uff09<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">terminal\u00a0: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u7ed3\u675f\u641c\u7d22\u5b57\u7b26\u4e32\uff08<\/span><span style=\"font-family:Arial\">char<\/span><span style=\"font-family:\u5b8b\u4f53\">\u578b\uff09<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t116\"\/>\u8fd4\u56de<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5982\u679c\u5728\u627e\u5230\u7ec8\u6b62\u5b57\u7b26<\/span><span style=\"font-family:Arial\">terminal<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e4b\u524d\u627e\u5230\u76ee\u6807\u5b57\u7b26<\/span><span style=\"font-family:Arial\">target<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u8fd4\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t117\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0target[]\u00a0=<span style=\"color:blue\">&#8220;test&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:seagreen; font-family:Consolas; font-size:9pt\"><strong>char<\/strong><span style=\"color:black\">\u00a0terminal[]\u00a0=<span style=\"color:blue\">&#8220;end&#8221;<span style=\"color:black\">;\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.begin(9600);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()&gt;=\u00a00){}<span style=\"color:#008200\">\/\/clear\u00a0serialbuffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\">\u00a0\u00a0\u00a0<br \/>\n\u00a0<\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop()\u00a0{\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0read\u00a0data\u00a0from\u00a0serial\u00a0port<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(Serial.available()&gt;0){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0delay(100);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>if<\/strong><span style=\"color:black\">(\u00a0Serial.findUntil(target,terminal)){\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.print(<span style=\"color:blue\">&#8220;find\u00a0traget:&#8221;<span style=\"color:black\">);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Serial.println(target);\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#008200\">\/\/\u00a0clear\u00a0serial\u00a0buffer<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0\u00a0\u00a0<span style=\"color:#006699\"><strong>while<\/strong><span style=\"color:black\">(Serial.read()\u00a0&gt;=\u00a00){}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#e36c0a; font-size:12pt\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t118\"\/>\u5b9e\u9a8c\u7ed3\u679c<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center; background: white\"><img decoding=\"async\" src=\"http:\/\/sxfu.tk\/wp-content\/uploads\/2017\/06\/060317_1401_Arduino13.jpg\" alt=\"\"\/><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5982\u679c\u4e32\u53e3\u7f13\u5b58\u4e2d\u6709\u76ee\u6807\u5b57\u7b26<\/span><span style=\"font-family:Arial\">&#8220;test&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u8fd4\u56de\u771f\uff0c\u4f46\u5982\u679c\u5148\u9047\u5230\u7ec8\u6b62\u5b57\u7b26\u4e32<\/span><span style=\"font-family:Arial\">&#8220;end&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5219\u51fd\u6570\u7acb\u5373\u7ec8\u6b62\uff0c\u4e0d\u8bba\u5b57\u7b26\u4e32\u540e\u9762\u6709\u6ca1\u6709\u76ee\u6807\u5b57\u7b26<\/span><span style=\"font-family:Arial\">&#8220;test&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#3366ff; font-size:18pt\"><strong><span style=\"font-family:Arial\"><a name=\"t119\"\/>6.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5411\u4e32\u53e3\u5199\u6570\u636e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#009900; font-family:Arial; font-size:13pt\"><strong><a name=\"t120\"\/>Serial.write();\u00a0\u00a0<span style=\"color:#006600\">\u00a0\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t121\"\/>\u8bf4\u660e<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u4e32\u53e3\u8f93\u51fa\u6570\u636e\u51fd\u6570\u3002\u5199\u4e8c\u8fdb\u5236\u6570\u636e\u5230\u4e32\u53e3\u3002<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t122\"\/>\u8bed\u6cd5<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333; font-family:Arial\">Serial.write(val)\u00a0<br \/>Serial.write(str)\u00a0<br \/>Serial.write(buf, len)<br \/>\n<\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t123\"\/>\u53c2\u6570<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:Arial\">val: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5b57\u8282<\/span><span style=\"font-family:Arial\">\u00a0<br \/>str: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e00\u4e32\u5b57\u8282<\/span><span style=\"font-family:Arial\">\u00a0<br \/>buf: <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5b57\u8282\u6570\u7ec4<\/span><span style=\"font-family:Arial\">\u00a0<br \/>len: buf<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u957f\u5ea6<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t124\"\/>\u8fd4\u56de<\/span><span style=\"font-family:Arial\">\u00a0<span style=\"color:#333333\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/strong><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#333333\"><span style=\"font-family:\u5b8b\u4f53\">\u5b57\u8282\u957f\u5ea6<\/span><span style=\"font-family:Arial\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: white\"><span style=\"color:#e36c0a\"><strong><span style=\"font-family:\u5b8b\u4f53\"><a name=\"t125\"\/>\u793a\u4f8b<\/span><span style=\"color:#333333; font-family:Arial\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #f8f8f8\"><span style=\"color:silver; font-family:Verdana; font-size:7pt\"><strong>[cpp]<\/strong>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"view plain\"><span style=\"color:#a0a0a0; text-decoration:underline\">view plain<\/span><\/a>\u00a0<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" title=\"copy\"><span style=\"color:#a0a0a0; text-decoration:underline\">copy<\/span><\/a><br \/>\n\t\t<\/span><\/p>\n<ol>\n<li>\n<div style=\"background: white\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0setup(){\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">Serial.begin(9600);\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:#006699; font-family:Consolas; font-size:9pt\"><strong>void<\/strong><span style=\"color:black\">\u00a0loop(){\u00a0\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t<\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0Serial.write(45);\u00a0<span style=\"color:#008200\">\/\/\u00a0send\u00a0a\u00a0byte\u00a0with\u00a0thevalue\u00a045\u00a0<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #f8f8f8\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">\u00a0\u00a0<span style=\"color:seagreen\"><strong>int<\/strong><span style=\"color:black\">\u00a0bytesSent\u00a0=\u00a0Serial.write(&#8220;hello&#8221;);\u00a0<span style=\"color:#008200\">\/\/sendthe\u00a0string\u00a0&#8220;hello&#8221;\u00a0and\u00a0return\u00a0the\u00a0length\u00a0of\u00a0the\u00a0string.\u00a0<span style=\"color:black\">\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t\t\t\t\t<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: white\"><span style=\"color:black; font-family:Consolas; font-size:9pt\">}\u00a0\u00a0<span style=\"color:#5c5c5c\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<p style=\"background: white\"><span style=\"color:#cc0000\"><span style=\"font-family:\u5b8b\u4f53\">\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041\" target=\"_blank\"\/><\/span><span style=\"color:#666666; font-family:Arial\"><span style=\"text-decoration:underline\">http:\/\/blog.csdn.net\/iracer\/article\/details\/50334041<\/span><span style=\"color:#333333\"><br \/>\n\t\t\t\t<\/span><\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Arduino &#8211;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-802","post","type-post","status-publish","format-standard","hentry","category-jishu"],"_links":{"self":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/802"}],"collection":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=802"}],"version-history":[{"count":0,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/802\/revisions"}],"wp:attachment":[{"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}