{"id":43132,"date":"2018-06-26T18:09:06","date_gmt":"2018-06-26T12:09:06","guid":{"rendered":"http:\/\/rcl-radio.ru\/?p=43132"},"modified":"2018-06-26T20:41:09","modified_gmt":"2018-06-26T14:41:09","slug":"%d1%83%d0%bf%d1%80%d0%b0%d0%b2%d0%bb%d1%8f%d0%b5%d0%bc-arduino-%d0%b8%d0%b7-php","status":"publish","type":"post","link":"http:\/\/rcl-radio.ru\/?p=43132","title":{"rendered":"\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c Arduino \u0438\u0437 PHP"},"content":{"rendered":"<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f php \u0438\u00a0 Arduino. \u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 Ubuntu 14.04, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0435\u0440 Apach\u0435 2, php 5.5. \u0412 \u0442\u0435\u0441\u0442\u0435 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 php.<\/p>\n<p><strong>test.php<\/strong><\/p>\n<pre style=\"background: #0c1021; color: #f8f8f8;\"><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">meta<\/span> <span style=\"color: #7f90aa;\">charset<\/span>=<span style=\"color: #61ce3c;\">\"utf-8\"<\/span>&gt;<\/span>\r\n<span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">table<\/span> <span style=\"color: #7f90aa;\">align<\/span>=<span style=\"color: #61ce3c;\">'center'<\/span> <span style=\"color: #7f90aa;\">width<\/span>=<span style=\"color: #61ce3c;\">\"200\"<\/span> <span style=\"color: #7f90aa;\">border<\/span>=<span style=\"color: #61ce3c;\">'0'<\/span> <span style=\"color: #7f90aa;\">cellspacing<\/span>=<span style=\"color: #61ce3c;\">'0'<\/span> <span style=\"color: #7f90aa;\">cellpadding<\/span>=<span style=\"color: #61ce3c;\">'5'<\/span>&gt;<\/span>\r\n\r\n<span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">form<\/span> <span style=\"color: #7f90aa;\">action<\/span>=<span style=\"color: #61ce3c;\">\"\"<\/span> <span style=\"color: #7f90aa;\">method<\/span>=<span style=\"color: #61ce3c;\">\"post\"<\/span>&gt;<\/span>\r\n<span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">td<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">button<\/span> <span style=\"color: #7f90aa;\">type<\/span>=<span style=\"color: #61ce3c;\">\"submit\"<\/span> <span style=\"color: #7f90aa;\">name<\/span>=<span style=\"color: #61ce3c;\">\"on\"<\/span>&gt;<\/span>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c<span style=\"color: #7f90aa;\">&lt;\/<span style=\"color: #7f90aa;\">button<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;\/<span style=\"color: #7f90aa;\">td<\/span>&gt;<\/span>\r\n<span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">td<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">button<\/span> <span style=\"color: #7f90aa;\">type<\/span>=<span style=\"color: #61ce3c;\">\"submit\"<\/span> <span style=\"color: #7f90aa;\">name<\/span>=<span style=\"color: #61ce3c;\">\"off\"<\/span>&gt;<\/span>\u0412\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c<span style=\"color: #7f90aa;\">&lt;\/<span style=\"color: #7f90aa;\">button<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">td<\/span>&gt;<\/span>\r\n<span style=\"color: #7f90aa;\">&lt;\/<span style=\"color: #7f90aa;\">form<\/span>&gt;<\/span>\r\n<span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">tr<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">td<\/span> <span style=\"color: #7f90aa;\">colspan<\/span>=<span style=\"color: #61ce3c;\">\"2\"<\/span>&gt;<\/span><span style=\"color: #7f90aa;\">&lt;<span style=\"color: #7f90aa;\">center<\/span>&gt;<\/span>\r\n&lt;?php\r\n<span style=\"color: #aeaeae;\">\/* \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0443:\r\nsudo chown www-data:www-data \/dev\/ttyUSB0                        \r\n*\/<\/span>\r\n$dev <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #61ce3c;\">\"\/dev\/ttyUSB0\"<\/span>;\r\n<span style=\"color: #8da6ce;\">exec<\/span>(<span style=\"color: #61ce3c;\">\"stty -F $dev 9600 raw -echo\"<\/span>);\r\n$f <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #8da6ce;\">fopen<\/span>($dev,<span style=\"color: #61ce3c;\">\"w+\"<\/span>);<span style=\"color: #aeaeae;\">\/\/ \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442<\/span>\r\n<span style=\"color: #fbde2d;\">if<\/span> (<span style=\"color: #fbde2d;\">!<\/span>$f)<span style=\"color: #fbde2d;\"> die<\/span> (<span style=\"color: #61ce3c;\">\"\u041e\u0448\u0438\u0431\u043a\u0430!!! \u041f\u043e\u0440\u0442 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u043b\u0441\u044f!\"<\/span>);\r\n\r\n<span style=\"color: #8da6ce;\">sleep<\/span>(<span style=\"color: #d8fa3c;\">2<\/span>);\r\n<span style=\"color: #aeaeae;\">\/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0432 \u043f\u043e\u0440\u0442<\/span>\r\n<span style=\"color: #fbde2d;\">if<\/span> (<span style=\"color: #8da6ce;\">isset<\/span>($_POST[<span style=\"color: #61ce3c;\">\"on\"<\/span>])){<span style=\"color: #8da6ce;\">fwrite<\/span>($f,<span style=\"color: #8da6ce;\">chr<\/span>(<span style=\"color: #d8fa3c;\">49<\/span>));<span style=\"color: #8da6ce;\">echo<\/span><span style=\"color: #61ce3c;\">\"ON\"<\/span>;}\r\n<span style=\"color: #fbde2d;\">if<\/span> (<span style=\"color: #8da6ce;\">isset<\/span>($_POST[<span style=\"color: #61ce3c;\">\"off\"<\/span>])){<span style=\"color: #8da6ce;\">fwrite<\/span>($f,<span style=\"color: #8da6ce;\">chr<\/span>(<span style=\"color: #d8fa3c;\">48<\/span>));<span style=\"color: #8da6ce;\">echo<\/span><span style=\"color: #61ce3c;\">\"OFF\"<\/span>;}\r\n\r\n<span style=\"color: #8da6ce;\">sleep<\/span>(<span style=\"color: #d8fa3c;\">2<\/span>);\r\n<span style=\"color: #aeaeae;\">\/\/ \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430<\/span>\r\n<span style=\"color: #fbde2d;\">while<\/span> (<span style=\"color: #8da6ce;\">fread<\/span>($f, <span style=\"color: #d8fa3c;\">1<\/span>) <span style=\"color: #fbde2d;\">!<\/span><span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #8da6ce;\">chr<\/span>(<span style=\"color: #d8fa3c;\">0xA<\/span>)){} <span style=\"color: #aeaeae;\">\/\/ \u0436\u0434\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0430<\/span>\r\n$a <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #8da6ce;\">fgets<\/span>($f);\r\n<span style=\"color: #8da6ce;\">echo<\/span> <span style=\"color: #61ce3c;\">\"&lt;br&gt;\u0412\u044b\u0445\u043e\u0434 13: \"<\/span><span style=\"color: #fbde2d;\">.<\/span> $a;\r\n  \r\n<span style=\"color: #8da6ce;\">fclose<\/span>($f); <span style=\"color: #aeaeae;\">\/\/ \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442<\/span>\r\n\r\n?&gt;\r\n<\/pre>\n<p><strong>\u0441\u043a\u0435\u0442\u0447<\/strong><\/p>\n<pre style=\"background: #0c1021; color: #f8f8f8;\"><span style=\"color: #8da6ce;\">void<\/span> setup(){\r\n  Serial.begin(<span style=\"color: #d8fa3c;\">9600<\/span>);\r\n  pinMode(<span style=\"color: #d8fa3c;\">13<\/span>, OUTPUT);\r\n}\r\nchar Byte;\r\n\r\n<span style=\"color: #8da6ce;\">void<\/span> loop(){\r\n  <span style=\"color: #fbde2d;\">if<\/span>( Serial.available() &gt; <span style=\"color: #d8fa3c;\">0<\/span> ){\r\n    Byte <span style=\"color: #fbde2d;\">=<\/span> Serial.read(); \r\n    <span style=\"color: #fbde2d;\">if<\/span>(Byte <span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #61ce3c;\">'1'<\/span>){\r\n      digitalWrite(<span style=\"color: #d8fa3c;\">13<\/span>,HIGH);\r\n    }\r\n    <span style=\"color: #fbde2d;\">if<\/span>(Byte <span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #61ce3c;\">'0'<\/span>){\r\n      digitalWrite(<span style=\"color: #d8fa3c;\">13<\/span>,LOW);\r\n    }\r\n  }\r\n  Serial.println(digitalRead(<span style=\"color: #d8fa3c;\">13<\/span>));<span style=\"color: #aeaeae;\">\/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0435 1000 \u043c\u0441<\/span>\r\n   delay(<span style=\"color: #d8fa3c;\">1000<\/span>);\r\n}\r\n<\/pre>\n<p>\u0427\u0435\u0440\u0435\u0437 \u043f\u043e\u0440\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u0430\u00a0\u00a0<strong>char<\/strong>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e <strong>chr(49)<\/strong> = 1, \u0430\u00a0<strong>chr(48)\u00a0<\/strong>= 0, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u0434\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432\u00a0<a href=\"http:\/\/arduino.ru\/Reference\/ASCIIchart\">\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 ASCII<\/a>. \u041f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043f\u043e\u0440\u0442\u0430, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0440\u0442 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u043f\u043b\u0430\u0442\u0435 Arduino \u0437\u0430\u0433\u043e\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u0433\u0430\u0441\u043d\u0435\u0442, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043a \u043f\u0438\u043d\u0443 13. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e, \u0442\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c, \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b Arduino, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435\u043c \u043f\u043e\u0440\u0442\u0430 php \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 Arduino. \u0412 \u0441\u043a\u0435\u0442\u0447\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0438\u043d\u0430 13 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0432 \u043f\u043e\u0440\u0442.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43133\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/643685324.png\" alt=\"\" width=\"207\" height=\"92\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/643685324.png 207w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/643685324-200x89.png 200w\" sizes=\"auto, (max-width: 207px) 100vw, 207px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43134\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/4376587236873249.png\" alt=\"\" width=\"227\" height=\"103\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/4376587236873249.png 227w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/4376587236873249-200x91.png 200w\" sizes=\"auto, (max-width: 227px) 100vw, 227px\" \/><\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u04101 \u0441\u043a\u0440\u0438\u043f\u0442\u0443 php.<\/p>\n<p>\u041f\u043e\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 3,3 \u0412 \u043d\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0439 \u0432\u0445\u043e\u0434 \u04101 \u0438 \u0438\u0437\u043c\u0435\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 php \u0441\u043a\u0440\u0438\u043f\u0442\u0430.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43138\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/723465874236.png\" alt=\"\" width=\"229\" height=\"100\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/723465874236.png 229w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/723465874236-200x87.png 200w\" sizes=\"auto, (max-width: 229px) 100vw, 229px\" \/><\/p>\n<p><strong>test.php<\/strong><\/p>\n<pre style=\"background: #0c1021; color: #f8f8f8;\">&lt;meta charset<span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"utf-8\"<\/span>&gt;\r\n&lt;table <span style=\"color: #8da6ce;\">align<\/span><span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">'center'<\/span> <span style=\"color: #8da6ce;\">width<\/span><span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"200\"<\/span> <span style=\"color: #8da6ce;\">border<\/span><span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">'0'<\/span> cellspacing<span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">'0'<\/span> cellpadding<span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">'5'<\/span>&gt;\r\n\r\n&lt;form action<span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"\"<\/span> <span style=\"color: #8da6ce;\">method<\/span><span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"post\"<\/span>&gt;\r\n&lt;td&gt;&lt;button <span style=\"color: #8da6ce;\">type<\/span><span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"submit\"<\/span>&gt;\u0418\u0437\u043c\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u04101&lt;<span style=\"color: #fbde2d;\">\/<\/span>button&gt;&lt;<span style=\"color: #fbde2d;\">\/<\/span>td&gt;\r\n&lt;<span style=\"color: #fbde2d;\">\/<\/span>form&gt;\r\n&lt;tr&gt;&lt;td colspan<span style=\"color: #fbde2d;\">=<\/span><span style=\"color: #61ce3c;\">\"2\"<\/span>&gt;&lt;center&gt;\r\n&lt;<span style=\"color: #fbde2d;\">?<\/span>php\r\n<span style=\"color: #aeaeae;\">\/* \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:\r\nsudo chown www-data:www-data \/dev\/ttyUSB0                        \r\n*\/<\/span>\r\n$dev <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #61ce3c;\">\"\/dev\/ttyUSB0\"<\/span>;\r\n<span style=\"color: #8da6ce;\">exec<\/span>(<span style=\"color: #61ce3c;\">\"stty -F $dev 9600 raw -echo\"<\/span>);\r\n$f <span style=\"color: #fbde2d;\">=<\/span> fopen($dev,<span style=\"color: #61ce3c;\">\"w+\"<\/span>);<span style=\"color: #aeaeae;\">\/\/ \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442<\/span>\r\n<span style=\"color: #fbde2d;\">if<\/span> (<span style=\"color: #fbde2d;\">!<\/span>$f) die (<span style=\"color: #61ce3c;\">\"\u041e\u0448\u0438\u0431\u043a\u0430!!! \u041f\u043e\u0440\u0442 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u043b\u0441\u044f!\"<\/span>);\r\n\r\nsleep(<span style=\"color: #d8fa3c;\">2<\/span>);\r\n<span style=\"color: #aeaeae;\">\/\/ \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430<\/span>\r\n<span style=\"color: #fbde2d;\">while<\/span> (fread($f, <span style=\"color: #d8fa3c;\">1<\/span>) <span style=\"color: #fbde2d;\">!<\/span><span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #8da6ce;\">chr<\/span>(<span style=\"color: #d8fa3c;\">0xA<\/span>)){} <span style=\"color: #aeaeae;\">\/\/ \u0436\u0434\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0430<\/span>\r\n$a <span style=\"color: #fbde2d;\">=<\/span> fgets($f);\r\necho <span style=\"color: #61ce3c;\">\"&lt;br&gt;\u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435: \"<\/span>. $a. <span style=\"color: #61ce3c;\">\"\u0412\"<\/span>;\r\n  \r\nfclose($f); <span style=\"color: #aeaeae;\">\/\/ \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0440\u0442<\/span>\r\n\r\n<span style=\"color: #fbde2d;\">?<\/span>&gt;\r\n&lt;<span style=\"color: #fbde2d;\">\/<\/span>td&gt;&lt;tr&gt;&lt;<span style=\"color: #fbde2d;\">\/<\/span>table&gt;\r\n<\/pre>\n<p><strong>\u0441\u043a\u0435\u0442\u0447<\/strong><\/p>\n<pre style=\"background: #0c1021; color: #f8f8f8;\"><span style=\"color: #8da6ce;\">void<\/span> setup(){\r\n  Serial.begin(<span style=\"color: #d8fa3c;\">9600<\/span>);\r\n  pinMode(A1,INPUT);\r\n}\r\n\r\nfloat u;\r\n<span style=\"color: #8da6ce;\">int<\/span> u1;\r\n\r\n<span style=\"color: #8da6ce;\">void<\/span> loop(){\r\n  u1<span style=\"color: #fbde2d;\">=<\/span>analogRead(A1);\r\n  u<span style=\"color: #fbde2d;\">=<\/span>u1<span style=\"color: #fbde2d;\">*<\/span><span style=\"color: #d8fa3c;\">5.0<\/span><span style=\"color: #fbde2d;\">\/<\/span><span style=\"color: #d8fa3c;\">1023<\/span>;\r\n  \r\n  Serial.println(u);<span style=\"color: #aeaeae;\">\/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0435 1000 \u043c\u0441<\/span>\r\n   delay(<span style=\"color: #d8fa3c;\">1000<\/span>);\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f php \u0438\u00a0 Arduino. \u0422\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 Ubuntu 14.04, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432\u0435\u0431 \u0441\u0435\u0440\u0432\u0435\u0440 Apach\u0435 2, php 5.5. \u0412 \u0442\u0435\u0441\u0442\u0435 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043d\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0430, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043e\u043f\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 php. test.php &lt;meta charset=&#187;utf-8&#8243;&gt; &lt;table align=&#8217;center&#8217; width=&#187;200&#8243; border=&#8217;0&#8242; cellspacing=&#8217;0&#8242; cellpadding=&#8217;5&#8242;&gt; &lt;form action=&#187;&#187; method=&#187;post&#187;&gt; &lt;td&gt;&lt;button type=&#187;submit&#187; name=&#187;on&#187;&gt;\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c&lt;\/button&gt;&lt;\/td&gt; &lt;td&gt;&lt;button type=&#187;submit&#187; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":43134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[],"class_list":["post-43132","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"views":4077,"_links":{"self":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=43132"}],"version-history":[{"count":4,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43132\/revisions"}],"predecessor-version":[{"id":43139,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43132\/revisions\/43139"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/media\/43134"}],"wp:attachment":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=43132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=43132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=43132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}