{"id":211919,"date":"2014-02-09T16:22:03","date_gmt":"2014-02-09T12:22:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=211919"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=211919","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u043b \u0440\u043e\u0431\u043e\u0442\u0430. \u0412\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u043e\u0431\u043e\u0442\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c. \u0418\u0445 \u0441\u0444\u0435\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u043c, \u043e\u043d\u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u043e\u0435\u043d\u043d\u043e\u0439 \u0441\u0444\u0435\u0440\u0435, \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0437\u0430\u0432\u0430\u043b\u043e\u0432, \u0442\u0430\u043a \u0436\u0435 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u00ab\u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439\u00bb, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u0440\u043e\u0431\u043e\u0442\u044b \u043f\u044b\u043b\u0435\u0441\u043e\u0441\u044b, \u0440\u043e\u0431\u043e\u0442\u044b-\u0434\u0440\u0443\u0437\u044c\u044f, \u0438 \u0442.\u0434.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u0430(\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0e2\/f2a\/b8d\/0e2f2ab8da914f969ad7d01f43e9110c.jpg\"\/><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041d\u0430\u0447\u043d\u0435\u043c<\/h4>\n<p>  <\/p>\n<h5>\u0413\u043e\u043b\u043e\u0432\u0430<\/h5>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430 \u0440\u043e\u0431\u043e\u0442\u0430 \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 Arduino Uno. \u041f\u043e\u0447\u0435\u043c\u0443? \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0430 \u0441 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0438\u043d\u0430\u043c\u0438 \u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u0421\u0430\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e\u0434 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 atmega328p \u044f \u043f\u0438\u0441\u0430\u043b \u0432 AtmelStudio \u043d\u0430 \u0421\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/c03\/8ef\/89d\/c038ef89d0b5a1b7c05fa7c9c232970a.png\"\/><\/p>\n<h5>\u041c\u043e\u0442\u043e\u0440\u044b<\/h5>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0435\u0441\u0430\u043c\u0438 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044f. \u042f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 Pololu TB6612FNG Dual Motor Driver Carrier(<a href=\"http:\/\/www.pololu.com\/product\/713\">\u044d\u0442\u043e\u043c<\/a>), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u0435\u043d, \u043b\u0435\u0433\u043a\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u043a\u0435\u0442\u043d\u0443\u044e \u043f\u043b\u0430\u0442\u0443, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0432\u0441\u0435 \u043c\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/945\/465\/a2a\/945465a2a77db4a5f18f76001dd54984.jpg\"\/><\/p>\n<p>  \u0414\u0432\u0430 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0430 \u043c\u043e\u0442\u043e\u0440-\u043a\u043e\u043b\u0435\u0441\u043e-\u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0431\u044b\u043b\u0438 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u044b <a href=\"http:\/\/www.pololu.com\/product\/1218\">\u0442\u0430\u043c \u0436\u0435<\/a>. \u0412 \u043d\u0435\u043c \u043a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u043d\u043a\u043e\u0434\u0435\u0440.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/918\/19e\/350\/91819e3508df199399a44f88bead0c84.jpg\"\/><\/p>\n<h5>\u041f\u0438\u0442\u0430\u043d\u0438\u0435<\/h5>\n<p>   \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Li-ion \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043a\u0441\u0442\u0430\u0442\u0438 \u0433\u043e\u0432\u043e\u0440\u044f \u0442\u043e\u0439 \u0436\u0435 \u0444\u0438\u0440\u043c\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/516\/276\/d4c\/516276d4caadf50d8402f86b49a61baf.jpg\"\/> <\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/df5\/786\/7fd\/df57867fdd4a1039f72d7830e1290d94.jpg\"\/><\/p>\n<h5>\u041d\u0443 \u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0438<\/h5>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u0434\u0432\u0443\u0445 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u043e\u0432 \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u043d\u0430 \u0440\u043e\u0431\u043e\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0443\u043b\u044c\u0442\u0440\u0430\u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u0434\u0430\u043b\u044c\u043d\u043e\u043c\u0435\u0440 hc-sr04. \u041a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0442\u0443\u0442 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/724\/d52\/c59\/724d52c591ed2e342a47355dabdcfd9c.jpg\"\/> <\/p>\n<p>  \u041d\u0443 \u0432\u043e\u0442, \u0434\u0443\u043c\u0430\u044e \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0440\u043e\u0431\u043e\u0442\u0430. \u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u044b\u043c, \u0430 \u0442\u043e\u0442 \u043a\u043e\u043c\u0443 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u0435 \u043d\u0430 \u043f\u043e\u0447\u0442\u0443.<\/p>\n<h4>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443<\/h4>\n<p>  \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0441\u0442\u043e\u044f\u0432\u0448\u0435\u0439 \u043f\u0435\u0440\u0435\u0434\u043e \u043c\u043d\u043e\u0439 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e \u0432\u044b\u0445\u043e\u0434\u0443 \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u043b\u0430\u0431\u0438\u0440\u0438\u043d\u0442\u0430. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430:<\/p>\n<ul>\n<li>\u0428\u0418\u041c \u2014 \u0434\u043b\u044f \u0440\u0435\u0433\u0443\u043b\u044f\u0446\u0438\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043c\u043e\u0442\u043e\u0440\u043e\u0432 <\/li>\n<li>\u0412\u043d\u0435\u0448\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f \u2014 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f\u0445 \u043e\u0442 \u0434\u0430\u0442\u0447\u0438\u043a\u0430(hc-sr04)<\/li>\n<li>16 \u0431\u0438\u0442\u043d\u044b\u0439 \u0442\u0430\u0439\u043c\u0435\u0440 \u2014 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u043d\u044b \u0438\u043c\u043f\u0443\u043b\u044c\u0441\u0430 \u0441 Echo \u043f\u043e\u0440\u0442\u0430 \u0434\u0430\u043b\u044c\u043d\u043e\u043c\u0435\u0440\u0430<\/li>\n<li>\u041d\u0443 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 \u2014 \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u044f \u0434\u0443\u043c\u0430\u044e \u043d\u0435 \u0441\u0442\u043e\u0438\u0442<\/li>\n<\/ul>\n<p>  \u0418\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043b\u0438\u0448\u044c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041c\u043d\u043e\u0433\u043e? \u041d\u0435\u0442! \u0412\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e!<\/p>\n<p>  \u0412\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432 \u0438\u0442\u043e\u0433\u0435:  <\/p>\n<pre><code class=\"cpp\">#include &lt;avr\/io.h&gt; #include &lt;util\/delay.h&gt; #include &lt;avr\/interrupt.h&gt;  #define motor1_0 0 #define motor1_1 1  #define motor2_0 4 #define motor2_1 7 \/\/#define F_CPU 16000000L  void work_func(); int getDist();  volatile int readTrue = 0;  volatile unsigned int d = 0;  int main() { \t \tDDRD = 255; \t \t\/\/\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0428\u0418\u041c \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439\t \tTCCR0A = (0&lt;&lt;COM0A0)|(1&lt;&lt;COM0A1)|(0&lt;&lt;COM0B0)|(1&lt;&lt;COM0B1)|(1&lt;&lt;WGM01)|(1&lt;&lt;WGM00); \tTCCR0B = (1&lt;&lt;FOC0A)|(1&lt;&lt;FOC0B)|(0&lt;&lt;WGM02)|(1&lt;&lt;CS00)|(0&lt;&lt;CS01)|(0&lt;&lt;CS02); \tOCR0A = 255; \/\/2 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c \tOCR0B = 248; \/\/1 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c \t \t\/\/ \u041f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f  \tDDRD &= ~(1 &lt;&lt; DDD2);  \tPORTD |= (1 &lt;&lt; PORTD2);  \tEICRA = (0 &lt;&lt; ISC01) | (1 &lt;&lt; ISC00);    \/\/ set INT0 to trigger on ANY logic change \tEIMSK |= (1 &lt;&lt; INT0);     \/\/ Turns on INT0 \tcli(); \/\/\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \t \t\/\/\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 TRIG \tDDRD |= (1 &lt;&lt; PORTD3); \t \t\/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 LED \tDDRB = 0b11111111; \t \twhile(1) \t{ \t\twork_func(); \t} }  void work_func() { \tif(getDist() &lt;= 10)  \t\t{ \t\t\t\/\/\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0431\u043b\u0438\u0436\u0435 \u0447\u0435\u043c 8 \u0441\u043c, \u0442\u043e \u043f\u043e\u0432\u0440\u043e\u0442 \u043d\u0430 90 \u0433\u0440\u0430\u0434 \u0432\u0440\u043f\u0430\u0432\u043e \t\t\tPORTB |= (1 &lt;&lt; PORTB5);    \t\t\tPORTD &= ~((1 &lt;&lt; motor1_0) | (1 &lt;&lt; motor2_0)); \t\t\tPORTD |= (1 &lt;&lt; motor1_0) | (1 &lt;&lt; motor2_1); \t\t\t_delay_ms(250); \t\t\tPORTD &= ~((1 &lt;&lt; motor1_0) | (1 &lt;&lt; motor2_1)); \t\t\t \t\t\tif(getDist() &lt;= 10) \t\t\t{ \t\t\t\t\/\/\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0431\u043b\u0438\u0436\u0435 \u0447\u0435\u043c 10 \u0441\u043c, \u0442\u043e \u043f\u043e\u0432\u0440\u043e\u0442 \u043d\u0430 180 \u0433\u0440\u0430\u0434 \u0432\u043b\u0435\u0432\u043e \t\t\t\tPORTD |= (1 &lt;&lt; motor1_1) | (1 &lt;&lt; motor2_0); \t\t\t\t_delay_ms(515); \t\t\t\tPORTD &= ~((1 &lt;&lt; motor1_1) | (1 &lt;&lt; motor2_0)); \t\t\t\t \t\t\t\tif(getDist() &lt;= 10) \t\t\t\t{ \t\t\t\t\t\/\/\u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0431\u043b\u0438\u0436\u0435 \u0447\u0435\u043c 10 \u0441\u043c, \u0442\u043e \u043f\u043e\u0432\u0440\u043e\u0442 \u043d\u0430 90 \u0433\u0440\u0430\u0434 \u0432\u043b\u0435\u0432\u043e \t\t\t\t\tPORTD |= (1 &lt;&lt; motor1_1) | (1 &lt;&lt; motor2_0); \t\t\t\t\t_delay_ms(250); \t\t\t\t\tPORTD &= ~((1 &lt;&lt; motor1_1) | (1 &lt;&lt; motor2_0)); \t\t\t\t} \t\t\t} \t\t} \t\t \t\telse \t\t{ \t\t\t\/\/ \u0415\u0441\u043b\u0438 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0432\u0438\u044f \u043d\u0435\u0442, \u0442\u043e \u0435\u0434\u0435\u043c \u0432\u043f\u0435\u0440\u0435\u0434. \t\t\tPORTB &= ~(1 &lt;&lt; PORTB5); \t\t\tPORTD |= (1 &lt;&lt; motor1_0) | (1 &lt;&lt; motor2_0); \t\t} \t\t\/\/PORTB &= ~(1 &lt;&lt; PORTB2); \t\t_delay_ms(120); }  int getDist() { \tPORTD |= (1 &lt;&lt; PORTD3); \t_delay_us(10); \tPORTD &= ~(1 &lt;&lt; PORTD3); \tsei(); \twhile(readTrue == 0); \tcli(); \treadTrue = 0; \tshort int cm =(short) d\/2\/58; \t\/\/ \treturn cm; }  ISR (INT0_vect) \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u043d\u0438\u044f (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430) { \tif((PIND & 4) != 0) \t{ \t\tTCCR1B = 2; \t} \telse \t{ \t\td = TCNT1; \t\tTCCR1B = 0; \t\tTCNT1 = 0; \t\t \t\treadTrue = 1; \t} } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u043e\u0431\u043e\u0442 \u0435\u0434\u0435\u0442 \u0432\u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u0442 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u0443\u0432\u0438\u0434\u0438\u0442 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0435\u0441\u044f \u0431\u043b\u0438\u0436\u0435 10 \u0441\u043c., \u043e\u043d \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043f\u0440\u0430\u0432\u043e \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432. \u0414\u0430\u043b\u0435\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e, \u0442\u043e \u043e\u043d \u0435\u0434\u0435\u0442 \u0432\u043f\u0435\u0440\u0435\u0434 \u0434\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f, \u0430 \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0442\u043e\u0436\u0435 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u043e \u0440\u043e\u0431\u043e\u0442 \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442 \u043d\u0430 180 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u0432\u043b\u0435\u0432\u043e \u0438 \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0435\u0441\u0442\u044c \u0442\u0430\u043c \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0438 \u0442\u0430\u043c \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u043e \u0440\u043e\u0431\u043e\u0442 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u0432\u043b\u0435\u0432\u043e(\u043d\u0430\u0437\u0430\u0434 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f) \u0438 \u0435\u0434\u0435\u0442 \u043d\u0430\u0437\u0430\u0434.  <\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u044f \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f AtmelStudio. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Arduino Sketch \u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441\u043e\u043a\u0440\u0430\u0442\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u044b.<\/p>\n<p>  P.S. \u042d\u0442\u043e \u043c\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0448\u0443 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043f\u0438\u043d\u0430\u0442\u044c \u0438 \u0435\u0441\u043b\u0438 \u0433\u0434\u0435-\u0442\u043e \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043e\u0448\u0438\u0431\u043a\u0438\/\u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0447\u043d\u043e. \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\/211919\/\"> http:\/\/habrahabr.ru\/post\/211919\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u043e\u0431\u043e\u0442\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u043d\u0430\u0448\u0443 \u0436\u0438\u0437\u043d\u044c. \u0418\u0445 \u0441\u0444\u0435\u0440\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0443\u0436\u0435 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u043c, \u043e\u043d\u0438 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u043e\u0435\u043d\u043d\u043e\u0439 \u0441\u0444\u0435\u0440\u0435, \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0437\u0430\u0432\u0430\u043b\u043e\u0432, \u0442\u0430\u043a \u0436\u0435 \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0431\u043e\u0442\u043e\u0432 \u00ab\u0434\u043b\u044f \u043b\u044e\u0434\u0435\u0439\u00bb, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u0440\u043e\u0431\u043e\u0442\u044b \u043f\u044b\u043b\u0435\u0441\u043e\u0441\u044b, \u0440\u043e\u0431\u043e\u0442\u044b-\u0434\u0440\u0443\u0437\u044c\u044f, \u0438 \u0442.\u0434.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u043e\u0431\u043e\u0442\u0430(\u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habr.habrastorage.org\/post_images\/0e2\/f2a\/b8d\/0e2f2ab8da914f969ad7d01f43e9110c.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-211919","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211919","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=211919"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211919\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}