{"id":244349,"date":"2014-11-27T19:20:03","date_gmt":"2014-11-27T15:20:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=244349"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=244349","title":{"rendered":"<span class=\"post_title\">\u0420\u0435\u043b\u0435 \u0441 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0418\u041a \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 ATtiny13a<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>  \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u043e\u0439, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0430\u043a\u0443\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043f\u0443\u043b\u044c\u0442\u0430 \u043e\u0442 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u0430, \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u0430\u044f \u0441 \u0434\u0438\u0432\u0430\u043d\u0430. \u041f\u043e\u0434\u0443\u043c\u0430\u0432, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0418\u041a \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a, \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043a\u0440\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u0430. \u0418\u041a \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0431\u0435\u0437 \u043e\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u043a\u043e\u0432. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0432\u044b\u0445\u043e\u0434\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0442\u044b\u043a\u0430 \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043e\u043d \u0438\u0437 \u0441\u0435\u0440\u0438\u0438 TSOP4xxx, \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435: <\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/734\/bb3\/324\/734bb332402445dea6eced4ba89458d7.jpg\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432 \u0438 \u043f\u043e\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u043d\u0430 Arduino UNO, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <a href=\"https:\/\/github.com\/nathanchantrell\/TinyPCRemote\/tree\/master\/TinyPCRemote_CodeReader\">\u044d\u0442\u043e\u0442 \u043a\u043e\u0434<\/a> \u0438 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430, \u044f \u043f\u0435\u0440\u0435\u0448\u0451\u043b \u043a \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u044e \u043a\u043e\u0434\u0430 \u043d\u0430 ATtiny13. \u041f\u0435\u0440\u0435\u0439\u0434\u044f \u043a \u043d\u0435\u0439, \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445, \u043a\u0430\u043a \u0432\u043e \u0444\u043b\u0435\u0448\u0435, \u0442\u0430\u043a \u0438 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e \u043d\u0430\u0447\u0430\u043b\u0443 \u0441 \u0442\u0440\u0443\u0434\u043e\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043a\u043e\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 64 \u0431\u0430\u0439\u0442, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432\u0437\u044f\u0442\u044c\u0441\u044f \u0437\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441 \u0433\u043e\u0440\u0435\u043c \u043f\u043e\u043f\u043e\u043b\u0430\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043e\u0434 \u0438 \u0441\u043e\u0431\u0440\u0430\u043b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043a\u0435. \u0420\u0430\u0434\u043e\u0432\u0430\u043b\u0441\u044f, \u043a\u0430\u043a \u0440\u0435\u0431\u0435\u043d\u043e\u043a! \u041e\u043d\u043e \u043c\u0438\u0433\u0430\u043b\u043e \u043b\u0430\u043c\u043f\u043e\u0447\u043a\u0430\u043c\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0430\u0434\u043e.<\/p>\n<p>  \u041e\u0431\u0449\u0438\u0439 \u0432\u0438\u0434:   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041c\u0430\u043a\u0435\u0442\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/467\/f4e\/845\/467f4e8452804fbdb0d38493f88a1734.JPG\"\/>  <\/div>\n<\/div>\n<p>  \u0421\u0445\u0435\u043c\u0430:   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u043e\u0439\u043b\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/b4f\/16c\/a91\/b4f16ca91a9d427b9cb98539787f2ddf.png\"\/>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u044e \u043c\u0430\u043a\u0435\u0442\u043a\u0443 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u043b\u0438\u0442. \u041f\u043b\u0430\u0442\u0443 \u0438\u0437\u0433\u043e\u0442\u043e\u0432\u043b\u044f\u043b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u041b\u0423\u0422. \u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u043b\u0438\u043d, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043a\u043e\u043c\u043e\u043c. \u0421\u0434\u0435\u043b\u0430\u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0445\u0435\u043c\u0443, \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0432 \u0438 \u0441\u043e\u0431\u0440\u0430\u0432, \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b LM317T. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043f\u043e\u043b\u043e\u043c\u0430\u0432 \u043f\u044f\u0442\u0430\u043a\u0438 \u0438 \u043e\u0442\u043e\u0440\u0432\u0430\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0442\u043e\u043d\u043a\u0438\u0435 \u0434\u043e\u0440\u043e\u0436\u043a\u0438, \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e \u043f\u043b\u0430\u0442\u0443. \u0412 \u043d\u0435\u0439 \u0441\u0434\u0435\u043b\u0430\u043b \u0434\u043e\u0440\u043e\u0436\u043a\u0438 0,7\u043c\u043c \u0438, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432 \u043f\u044f\u0442\u0430\u043a\u0438, \u043a\u043e\u0435 \u043a\u0430\u043a \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441 \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c. \u0422\u0443\u0442 \u0442\u043e\u0436\u0435 \u043d\u0435 \u043e\u0431\u043e\u0448\u043b\u043e\u0441\u044c \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u044f\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b LM317T, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043b\u0430\u0442\u044b \u0441\u0436\u0435\u0433 \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a, \u043f\u043e\u0434\u0430\u0432 \u043d\u0430 \u043d\u0435\u0433\u043e 12\u0412.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043e\u0442 12\u0412 (\u0431\u044b\u043b \u0443 \u043c\u0435\u043d\u044f \u043c\u0430\u043b\u043e\u043c\u043e\u0449\u043d\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0440, \u0432\u043e\u0442 \u0435\u0433\u043e \u0438 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043b). \u0412\u044b\u0431\u043e\u0440 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u043e\u0431\u0443\u0441\u043b\u043e\u0432\u043b\u0435\u043d \u0442\u0430\u043a \u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u043c\u0441\u044f \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0440\u0435\u043b\u0435 \u043d\u0430 12\u0412. \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0434\u043e 5\u0412 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0442\u043e\u0440 LM317T, \u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 npn \u0442\u0440\u0430\u043d\u0437\u0438\u0441\u0442\u043e\u0440 \u041a\u0422819. <\/p>\n<p>  \u041e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0432 SprintLayout:   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u043e\u0439\u043b\u0435\u0440<\/b><\/p>\n<div class=\"spoiler_text\"><img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/2d9\/106\/a51\/2d9106a5110a4df89a4d8b3201130627.png\"\/>  <\/div>\n<\/div>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438:  <\/p>\n<ul>\n<li>\u041c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 ATtiny13A;<\/li>\n<li>\u0420\u0435\u0437\u0438\u0441\u0442\u043e\u0440\u044b \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u043c 470, 1300, 2&#215;330 \u0438 90 \u041e\u043c;<\/li>\n<li>\u0422\u0440\u0430\u043d\u0437\u0438\u0441\u0442\u043e\u0440 \u041a\u0422819;<\/li>\n<li>\u0421\u0442\u0430\u0431\u0438\u043b\u0438\u0437\u0430\u0442\u043e\u0440 LM317T;<\/li>\n<li>2 \u0441\u0432\u0435\u0442\u043e\u0434\u0438\u043e\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438 \u0437\u0435\u043b\u0435\u043d\u044b\u0439;<\/li>\n<li>\u041f\u0440\u0438\u0451\u043c\u043d\u0438\u043a \u0441\u0435\u0440\u0438\u0438 TSOP4XXX \u0438\u043b\u0438 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b\u0439;<\/li>\n<li>2 \u043a\u043e\u043d\u0434\u0435\u043d\u0441\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 200-220\u043c\u043a\u0424.<\/li>\n<\/ul>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u00ab\u0443\u0432\u0435\u0441\u0438\u0441\u0442\u044b\u0439\u00bb \u0438 \u043d\u0430 ATtiny13 \u043d\u0438 \u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0433 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u044f\u0436\u0435\u043b\u043e\u0433\u043e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041a\u043e\u0434 \u0431\u044b\u043b \u043e\u0447\u0435\u043d\u044c \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c: \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0442\u0430\u043a \u0436\u0435 \u00ab\u043d\u0438\u0437\u043a\u0438\u0435\u00bb \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u044b, \u043d\u043e \u043e\u043d\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c. \u0412 \u043e\u0431\u0449\u0435\u043c, \u0432\u044b\u043a\u0438\u043d\u0443\u043b \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u044d\u0442\u0438\u043c \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u043b \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 64 \u0431\u0430\u0439\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u043d\u0430 \u043b\u0435\u0442\u0443, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0443\u0440\u0435\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f Arduino IDE<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>#define IRpin_PIN PINB #define IRpin 2  #define rLedPin 3 #define gLedPin 4 #define relayPin 1  #define MAXPULSE 5000 #define NUMPULSES 32 #define RESOLUTION 2  #define timeN1 1800000 #define timeN2 3600000  #define timerInterval 500   bool relayState = false; unsigned long timer = 0; unsigned long shift = timeN1;\/\/30 min timer by default unsigned long previousMillis = 0; bool timerN = false; byte i = 0;   void setup() {   \/\/default states   DDRB |= (1&lt;&lt;relayPin);   DDRB |= (1&lt;&lt;rLedPin);   DDRB |= (1&lt;&lt;gLedPin);    PORTB &= ~(1&lt;&lt;relayPin);\/\/relay off   PORTB &= ~(1&lt;&lt;rLedPin);\/\/red led off   PORTB |=  (1&lt;&lt;gLedPin);\/\/green led on    \/*   \/\/for debug   Serial.begin(9600);   Serial.println(&quot;Start | &quot;+String(millis()));   \/\/*\/    \/*   \/\/for debug without ir receiver   pinMode(5, INPUT);   pinMode(6, INPUT);   \/\/*\/   }  void shutDown(){   relayState = true;   PORTB |=  (1&lt;&lt;relayPin);   PORTB &= ~(1&lt;&lt;gLedPin);   PORTB |=  (1&lt;&lt;rLedPin);   \/\/Serial.println(&quot;turining off |&quot;+String(millis())); }  void startUp(){   relayState = false;   PORTB &= ~(1&lt;&lt;relayPin);   PORTB |=  (1&lt;&lt;gLedPin);   PORTB &= ~(1&lt;&lt;rLedPin);   \/\/Serial.println(&quot;turining on |&quot;+String(millis())); }  void loop() {   unsigned long irCode = listenForIR(); \/\/ Wait for an IR Code   \/\/Serial.println(&quot;ir code: &quot;+String(irCode));   if(irCode == 3359105948){\/\/green button     \/\/Serial.println(&quot;Pressed green btn |&quot;+String(millis()));     if(timer == 0){\/\/on off mode       if(relayState == true){         startUp();       }else{         shutDown();       }     }else{\/\/cancel timer mode       timer = 0;       PORTB &= ~(1&lt;&lt;rLedPin);\/\/turn off red led       \/\/Serial.println(&quot;timer canceled |&quot;+String(millis()));     }   }\/\/end green btn     if(3359101868 == irCode){\/\/red btn     \/\/Serial.println(&quot;pressed red btn |&quot;+String(millis()));     if(timer == 0){       if(relayState == 0){         timer = millis();         \/\/Serial.println(&quot;timer started |&quot;+String(millis()));       }\/*else{         Serial.println(&quot;already shutdown |&quot;+String(millis()));       }       \/\/*\/      }else{\/\/changing time mode       timerN = !timerN;       if(timerN){         \/\/Serial.println(&quot;change 30sec |&quot;+String(millis()));         shift = timeN1;\/\/30 min       }else{         \/\/Serial.println(&quot;change 60sec |&quot;+String(millis()));         shift = timeN2;\/\/60 min       }     }   }\/\/end red btn } \/\/ loop end  void checkTimer(){   unsigned long time = millis();   if(time - previousMillis &gt;= timerInterval || previousMillis &gt; time ) {     previousMillis =time;     timer1();   } }  unsigned long  listenForIR() {\/\/ IR receive code   byte currentpulse = 0; \/\/ index for pulses we're storing   unsigned long irCode = 0; \/\/ Wait for an IR Code   irCode = irCode &lt;&lt; 1;    while (true) {     unsigned int pulse = 0;\/\/ temporary storage timing     \/\/bool true (HIGH)     while (IRpin_PIN & _BV(IRpin)) { \/\/ got a high pulse (99% standby time have HIGH)       if(++i &gt; 150){\/\/check timer every 150 iterations (high frequency break ir code timing)         i = 0;         checkTimer();       }       pulse++;       delayMicroseconds(RESOLUTION);       if (((pulse &gt;= MAXPULSE) && (currentpulse != 0)) || currentpulse == NUMPULSES ) {         return irCode;       }     }  \t\/\/make irCode     irCode = irCode &lt;&lt; 1;     if ((pulse * RESOLUTION) &gt; 0 && (pulse * RESOLUTION) &lt; 500) {       irCode |= 0;     }else {       irCode |= 1;     }     currentpulse++; \tpulse = 0;         \/\/bool false (LOW)     while (!(IRpin_PIN & _BV(IRpin))) {\/\/wait before new pulse       \/\/checkTimer();       pulse++;       delayMicroseconds(RESOLUTION);       if (pulse &gt;= MAXPULSE || currentpulse == NUMPULSES ) {         \/\/Serial.println(irCode);         return irCode;       }     }   }\/\/end while(1)    }\/\/end listenForIR    \/\/executing every timerInverval void timer1() {   if(timer != 0){     if(timerN == true){\/\/timeN1 or timeN2       PORTB |= (1&lt;&lt;rLedPin);     }else{\/\/blinking 30min\t       PORTB ^= (1&lt;&lt;rLedPin);\/\/invert     }     \/\/Serial.println(String((timer+shift - millis())\/1000));   }    if(timer != 0 &&(timer+shift &lt; millis() || timer &gt; millis())){     timer = 0;     shutDown();   } }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u0435\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f:<\/p>\n<p>  <iframe loading=\"lazy\" width=\"560\" height=\"349\" src=\"\/\/www.youtube.com\/embed\/gp7GlFxuZU8?wmode=opaque\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>  \u041f\u0440\u043e\u0448\u0438\u0432\u0430\u043b ATtiny13 \u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Arduino UNO, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0433\u043e \u043a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u0442\u043e\u0440, \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0443\u044f\u0441\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/234477\/\">\u00ab\u041f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ATtiny13 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Arduino\u00bb<\/a>. \u0414\u043b\u044f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b 9,6\u041c\u0413\u0446 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e.<\/p>\n<p>  \u0424\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0434\u0435\u043b\u0430\u043b, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0442\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\u0418\u0437 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0441\u043f\u0438\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0430\u0441\u043d\u043e\u0433\u043e TSOP \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043d\u0430 \u043f\u0440\u043e\u0432\u043e\u0434\u043a\u0438 \u0438 \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043a\u043b\u0435\u0435\u043c (\u043f\u043e\u0437\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u043b \u043a \u043a\u043e\u0440\u043f\u0443\u0441\u0443).<\/p>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441\u0431\u043e\u043a\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/ad2\/f16\/cfe\/ad2f16cfe64f40158382273a6328e30d.JPG\"\/><\/p>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441\u0432\u0435\u0440\u0445\u0443 (\u0438\u043a \u0434\u0430\u0442\u0447\u0438\u043a \u043f\u0435\u0440\u0435\u043d\u0435\u0441):<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/b51\/366\/439\/b513664399534745bd2d72d9175a163e.JPG\"\/><\/p>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441\u043d\u0438\u0437\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/7f4\/930\/0c1\/7f49300c1eb146a1b965fd35e2e77cdd.JPG\"\/><\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e:<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/226\/bd9\/d66\/226bd9d668484c10bdc23073e1fe6adc.JPG\"\/>  <\/div>\n<\/div>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0438 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/yadi.sk\/d\/RZOLDVuacw2xL\">\u044f\u043d\u0434\u0435\u043a\u0441 \u0434\u0438\u0441\u043a\u0435<\/a>.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h4>\n<p>  <a href=\"http:\/\/myrobot.ru\/wiki\/index.php?n=Components.TSOP\">myrobot.ru\/wiki\/index.php?n=Components.TSOP<\/a> \u0412\u0441\u0451 \u043e\u0431 \u0418\u041a-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u0435 \u00abTSOP\u00bb<br \/>  <a href=\"http:\/\/www.atmel.com\/images\/doc2535.pdf\">www.atmel.com\/images\/doc2535.pdf<\/a> \u0414\u0430\u0442\u0430\u0448\u0438\u0442 \u043f\u043e ATtiny13<br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/234477\/\">habrahabr.ru\/post\/234477\/<\/a> \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0435 ATtiny13<br \/>  <a href=\"http:\/\/payalo.at.ua\/c_fuse\/calc.html?part=ATtiny13A\">payalo.at.ua\/c_fuse\/calc.html?part=ATtiny13A<\/a> \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u0444\u044c\u044e\u0437\u043e\u0432 \u0434\u043b\u044f ATtiny13<br \/>  <a href=\"https:\/\/github.com\/nathanchantrell\/TinyPCRemote\/tree\/master\/TinyPCRemote_CodeReader\">github.com\/nathanchantrell\/TinyPCRemote\/tree\/master\/TinyPCRemote_CodeReader<\/a>, \u043a\u043e\u0434 \u0447\u0438\u0442\u0430\u043b\u043a\u0438 \u043a\u043e\u0434\u043e\u0432 \u043f\u0443\u043b\u044c\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0432\u0437\u044f\u043b \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/244349\/\"> http:\/\/habrahabr.ru\/post\/244349\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! <\/p>\n<p>  \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u043e\u0439, \u043d\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u0430\u043a\u0443\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043f\u0443\u043b\u044c\u0442\u0430 \u043e\u0442 \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u0430, \u043d\u0435 \u0432\u0441\u0442\u0430\u0432\u0430\u044f \u0441 \u0434\u0438\u0432\u0430\u043d\u0430. \u041f\u043e\u0434\u0443\u043c\u0430\u0432, \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0418\u041a \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a, \u043d\u0435\u043a\u043e\u0433\u0434\u0430 \u0432\u044b\u043a\u0440\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u0430. \u0418\u041a \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0431\u0435\u0437 \u043e\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u043a\u043e\u0432. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0432 \u0432\u044b\u0445\u043e\u0434\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0442\u044b\u043a\u0430 \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u043e\u043d \u0438\u0437 \u0441\u0435\u0440\u0438\u0438 TSOP4xxx, \u0435\u0441\u043b\u0438 \u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435: <\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/734\/bb3\/324\/734bb332402445dea6eced4ba89458d7.jpg\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-244349","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/244349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244349"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/244349\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}