{"id":6955,"date":"2025-03-30T08:32:47","date_gmt":"2025-03-30T04:32:47","guid":{"rendered":"https:\/\/gameforstreet.ru\/?p=6474"},"modified":"2025-03-30T08:32:47","modified_gmt":"2025-03-30T04:32:47","slug":"zaderzhka-v-node-js-upravlyaem-svetodiodami-cherez-pk-na-atmega88","status":"publish","type":"post","link":"https:\/\/xn--c1aaoofgb.xn--p1acf\/?p=6955","title":{"rendered":"\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0432 Node.js: \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u041f\u041a \u043d\u0430 Atmega88"},"content":{"rendered":"<p>\u041a\u0430\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 (\u043f\u0430\u0443\u0437\u0430, delay) \u0432 Node.js (JavaScript).<br \/>\n\u0412\u043a\u043b\u044e\u0447\u0430\u044e \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u044b \u0447\u0435\u0440\u0435\u0437 Node.js (JavaScript) \u0447\u0435\u0440\u0435\u0437 Uart \u043d\u0430 Atmega88, \u0432\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0439), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &#8211; \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<!--more--><\/p>\n<p>\u041a\u0430\u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Node.js &#8211;  &#8220;gameforstreet.ru\/ustanavlivaem-node-js\/&#8221;<br \/>\n\u0420\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430 Linux: \u041e\u0421 Linux Rosa FResh R12 Plasma<br \/>\n\u041f\u041a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d \u0447\u0435\u0440\u0435\u0437 (USB-UART) \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u2013 HW-597 (\u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435 CH340), \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u043c\u0443 \u043d\u0430 Atmega88 (\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 Atmega: ATtiny45\/85, ATtiny2313\/AT90S2313 \u0438 ATmega8\/48\/88\/168), \u0432\u043e\u0442 \u043f\u0438\u0441\u0430\u043b \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438:<br \/>\n&#8220;gameforstreet.ru\/usb-ttl-usb-uart-preobrazovatel-na-atmega\/&#8221;<br \/>\n\u0410 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c COM-TTL \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c &#8211; \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0435 max232 &#8211; \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0437\u0434\u0435\u0441\u044c &#8211; \u0441\u0445\u0435\u043c\u0430 \u0438 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<br \/>\n&#8220;gameforstreet.ru\/uart-pic16f690\/&#8221;<\/p>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 (&#8220;gameforstreet.ru\/atmega88-upravlyaem-svetodiodami-s-pk-po-uart-bez-kvarca-vnutrennij-rc-generator-8mgc\/&#8221;) :<\/p>\n<p><a href=\"https:\/\/gameforstreet.ru\/wp-content\/uploads\/2025\/03\/ATmega88uart8gc.png\"><img loading=\"lazy\" src=\"https:\/\/gameforstreet.ru\/wp-content\/uploads\/2025\/03\/ATmega88uart8gc.png\" alt=\"\" width=\"768\" height=\"311\" class=\"alignnone size-full wp-image-6462\" \/><\/a><\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u0437\u0430\u0436\u0438\u0433\u0430\u044e \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c\u0443 Atmega88 \u0446\u0438\u0444\u0440\u044b \u043e\u0442 1 \u0434\u043e 4 (1 \u0437\u0430\u0436\u0438\u0433\u0430\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434, 2 \u0433\u0430\u0441\u0438\u0442 \u0435\u0433\u043e, 3 \u0437\u0430\u0436\u0438\u0433\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434, 4 \u0433\u0430\u0441\u0438\u0442 \u0435\u0433\u043e). \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e \u0446\u0438\u0444\u0440\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\nmyPort.write('1');\n<\/pre>\n<p>\u0412\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0442\u043e\u0440\u043c\u043e\u0436\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\nsetTimeout (l2,3000);\nsetTimeout (l3,5000);\nsetTimeout (l4,7000);\n<\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e l2 \u0437\u0430\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u043b \u043d\u0430 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b, l3 &#8211; \u043d\u0430 5 \u0441\u0435\u043a\u0443\u043d\u0434, l4 \u043d\u0430 7 \u0441\u0435\u043a\u0443\u043d\u0434!<\/p>\n<p>\u041a\u043e\u0434:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\nconst { SerialPort } = require('serialport')\nconst myPort = new SerialPort({ path: '\/dev\/ttyUSB0', baudRate: 9600 })\n\n\nvar fs = require('fs');\nfs.open('dataout.txt', 'w', function (err, file) {\n  if (err) throw err;});\nvar readline = require('readline-sync');\n\nvar i=0;\nvar j=0;\nvar k=0;\nvar sum=0;\nvar kk=0;\nvar a = new Array();\nvar lth = new Array();\nvar nval = new Array();\nvar xx,yy,xxn,yyn;\nvar ntot = readline.question(&quot;input ntot:  &quot;);  \/\/Input the number of bytes to be read\n\nmyPort.on('open', showPortOpen);\n\nfunction l1 ()\n{\n    myPort.write('1');\n}\n\nfunction l2 ()\n{\n    myPort.write('2');\n}\n\nfunction l3 ()\n{\n    myPort.write('3');\n}\n\nfunction l4 ()\n{\n    myPort.write('4');\n    myPort.on('close', showPortClose);\n    myPort.on('error', showError);\n    myPort.on('data', readdata);\n\n}\n\nl1 ();\nsetTimeout (l2,3000);\nsetTimeout (l3,5000);\nsetTimeout (l4,7000);\n\n\nconsole.log(&quot;\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0434\u0430\u043d\u043d\u044b\u0435&quot;);\n\nfunction readdata()\n{\n    myPort.close(showPortClose());\n\n}\nfunction showPortOpen() {\n   myPort.flush();\n}\n\n\n function showPortClose() {\n   console.log('port closed.');\n}\n\nfunction showError(error) {\n   console.log('Serial port error: ' + error);\n}\n\nmyPort.open(function (err) {\n  if (err) {\n    return console.log('Error opening port: ', err.message);\n  }});\n\n<\/pre>\n<p>\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0444\u0430\u0439\u043b node.js \u0441 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c:<br \/>\n<a href=\"https:\/\/gameforstreet.ru\/wp-content\/uploads\/2025\/03\/nodjssvetatmega88.tar.gz\" rel=\"noopener noreferrer\" target=\"_blank\">&#8211; \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 tar.gz<\/a><br \/>\n<a href=\"https:\/\/gameforstreet.ru\/wp-content\/uploads\/2025\/03\/nodsvetatmega88.zip\" rel=\"noopener noreferrer\" target=\"_blank\">&#8211; \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 (\u043f\u0430\u0443\u0437\u0430, delay) \u0432 Node.js (JavaScript). \u0412\u043a\u043b\u044e\u0447\u0430\u044e \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u044b \u0447\u0435\u0440\u0435\u0437 Node.js (JavaScript) \u0447\u0435\u0440\u0435\u0437 Uart \u043d\u0430 Atmega88, \u0432\u043e\u0442 \u043a\u043e\u0434 \u043c\u043e\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0439), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e &#8211; \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n","protected":false},"author":2,"featured_media":6490,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[105,103],"tags":[],"_links":{"self":[{"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/posts\/6955"}],"collection":[{"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6955"}],"version-history":[{"count":0,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/posts\/6955\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=\/wp\/v2\/media\/6490"}],"wp:attachment":[{"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xn--c1aaoofgb.xn--p1acf\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}