{"id":68974,"date":"2020-01-03T21:20:12","date_gmt":"2020-01-03T15:20:12","guid":{"rendered":"http:\/\/rcl-radio.ru\/?p=68974"},"modified":"2022-01-09T13:08:05","modified_gmt":"2022-01-09T07:08:05","slug":"stm32-%d1%8d%d0%bd%d0%ba%d0%be%d0%b4%d0%b5%d1%80-ky-040-arduino-ide","status":"publish","type":"post","link":"http:\/\/rcl-radio.ru\/?p=68974","title":{"rendered":"STM32 + \u044d\u043d\u043a\u043e\u0434\u0435\u0440 ky-040 (Arduino IDE)"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/07\/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA-%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0-%D0%BE%D1%82-2018-07-28-174033.png\" width=\"171\" height=\"175\" \/>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 ky-040 \u043a \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 STM32 \u0431\u0430\u0437\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 STM32F103C8T6 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e \u043a \u043f\u043b\u0430\u0442\u0435 Arduino Nano (Uno), \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0440\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430.<\/p>\n<p>\u042d\u043d\u043a\u043e\u0434\u0435\u0440 ky-040 \u0438\u043c\u0435\u0435\u0442 \u043f\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432 (\u044d\u043d\u043a\u043e\u0434\u0435\u0440 &gt; STM32):<\/p>\n<ul>\n<li>GND &gt; G<\/li>\n<li>+\u00a0 &gt; 3.3<\/li>\n<li>CLK &gt; \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434<\/li>\n<li>DT &gt; \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434<\/li>\n<li>SW &gt;\u00a0\u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434 (\u041a\u043d\u043e\u043f\u043a\u0430 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430)<\/li>\n<\/ul>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 10px;\"><span style=\"color: #808080; font-style: italic;\">#define pinA PB11<\/span>\r\n<span style=\"color: #808080; font-style: italic;\">#define pinB PB10<\/span>\r\n<span style=\"color: #808080; font-style: italic;\">#define SW   PB1<\/span>\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">#include &lt;STM32_Encoder.h&gt; \/\/ <a href=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/STM32_Encoder.zip\">http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/<strong>STM32_Encoder.zip<\/strong><\/a><\/span>\r\n  STM32_Encoder encoder<span style=\"color: #66cc66;\">(<\/span>pinA, pinB<span style=\"color: #66cc66;\">)<\/span>;\r\n  <span style=\"color: #0066cc;\">int<\/span> <span style=\"color: #0066cc;\">position<\/span> = <span style=\"color: #cc66cc;\">0<\/span>;\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> Read<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>encoder.<span style=\"color: #006600;\">readAB<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> setup<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n  encoder.<span style=\"color: #006600;\">begin<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;                                                         \r\n  attachInterrupt<span style=\"color: #66cc66;\">(<\/span>digitalPinToInterrupt<span style=\"color: #66cc66;\">(<\/span>pinA<span style=\"color: #66cc66;\">)<\/span>,Read,CHANGE<span style=\"color: #66cc66;\">)<\/span>;  \r\n  attachInterrupt<span style=\"color: #66cc66;\">(<\/span>digitalPinToInterrupt<span style=\"color: #66cc66;\">(<\/span>pinB<span style=\"color: #66cc66;\">)<\/span>,Read,CHANGE<span style=\"color: #66cc66;\">)<\/span>; \r\n  Serial.<span style=\"color: #006600;\">begin<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">115200<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n  <span style=\"color: #808080; font-style: italic;\">\/\/ encoder.setPosition(0);\/\/ \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f<\/span>\r\n  pinMode<span style=\"color: #66cc66;\">(<\/span>SW,INPUT<span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ SW <\/span>\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> loop<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n\u00a0\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #0066cc;\">position<\/span> <span style=\"color: #66cc66;\">!<\/span>= encoder.<span style=\"color: #006600;\">getPosition<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n    <span style=\"color: #0066cc;\">position<\/span> = encoder.<span style=\"color: #006600;\">getPosition<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n    Serial.<span style=\"color: #006600;\">println<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #0066cc;\">position<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>digitalRead<span style=\"color: #66cc66;\">(<\/span>SW<span style=\"color: #66cc66;\">)<\/span>==LOW<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>Serial.<span style=\"color: #006600;\">println<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">\"button\"<\/span><span style=\"color: #66cc66;\">)<\/span>;delay<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">300<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<div id=\"marketWidget\"><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-68976\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/\u0421\u043d\u0438\u043c\u043e\u043a-\u044d\u043a\u0440\u0430\u043d\u0430-\u043e\u0442-2020-01-03-211945.png\" alt=\"\" width=\"369\" height=\"512\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/\u0421\u043d\u0438\u043c\u043e\u043a-\u044d\u043a\u0440\u0430\u043d\u0430-\u043e\u0442-2020-01-03-211945.png 369w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/\u0421\u043d\u0438\u043c\u043e\u043a-\u044d\u043a\u0440\u0430\u043d\u0430-\u043e\u0442-2020-01-03-211945-200x278.png 200w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2020\/01\/\u0421\u043d\u0438\u043c\u043e\u043a-\u044d\u043a\u0440\u0430\u043d\u0430-\u043e\u0442-2020-01-03-211945-360x500.png 360w\" sizes=\"auto, (max-width: 369px) 100vw, 369px\" \/><\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u043b\u0438\u0432\u043a\u043e\u0439 \u0441\u043a\u0435\u0442\u0447\u0430 \u0432 STM32 \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u2014\u00a0<a href=\"http:\/\/rcl-radio.ru\/?p=68376\">STM32 Arduino IDE<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430 ky-040 \u043a \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0435 STM32 \u0431\u0430\u0437\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 STM32F103C8T6 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e \u043a \u043f\u043b\u0430\u0442\u0435 Arduino Nano (Uno), \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0440\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0445 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044d\u043d\u043a\u043e\u0434\u0435\u0440\u0430. \u042d\u043d\u043a\u043e\u0434\u0435\u0440 ky-040 \u0438\u043c\u0435\u0435\u0442 \u043f\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432 (\u044d\u043d\u043a\u043e\u0434\u0435\u0440 &gt; STM32): GND &gt; G +\u00a0 &gt; 3.3 CLK &gt; \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434 DT &gt; \u043b\u044e\u0431\u043e\u0439 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0432\u0445\u043e\u0434 SW &gt;\u00a0\u043b\u044e\u0431\u043e\u0439 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":68978,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[],"class_list":["post-68974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"views":6721,"_links":{"self":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/68974","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=68974"}],"version-history":[{"count":6,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/68974\/revisions"}],"predecessor-version":[{"id":111292,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/68974\/revisions\/111292"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/media\/68978"}],"wp:attachment":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68974"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}