{"id":43165,"date":"2018-06-28T20:15:01","date_gmt":"2018-06-28T14:15:01","guid":{"rendered":"http:\/\/rcl-radio.ru\/?p=43165"},"modified":"2022-01-14T21:23:11","modified_gmt":"2022-01-14T15:23:11","slug":"%d1%84%d1%83%d0%bd%d0%ba%d1%86%d0%b8%d0%b8-highbyte-%d0%b8-lowbyte-arduino","status":"publish","type":"post","link":"http:\/\/rcl-radio.ru\/?p=43165","title":{"rendered":"\u0424\u0443\u043d\u043a\u0446\u0438\u0438 highByte() \u0438 lowByte() (Arduino)"},"content":{"rendered":"<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 highByte() \u0438 lowByte() \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0438 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 <strong>int<\/strong>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u043a int, \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442\u0430\u0445.<\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f lowByte() \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 highByte() &#8212; \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/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\r\n  long <span style=\"color: #8da6ce;\">x<\/span> <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #d8fa3c;\">10000<\/span>; <span style=\"color: #aeaeae;\">\/\/ \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e &gt; 255 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u043d\u0430 2 \u0431\u0430\u0439\u0442\u0430 (\u043c\u0430\u043a\u0441. 65536)<\/span>\r\n  byte hi <span style=\"color: #fbde2d;\">=<\/span> highByte(<span style=\"color: #8da6ce;\">x<\/span>); <span style=\"color: #aeaeae;\">\/\/ \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0430\u0439\u0442<\/span>\r\n  byte low <span style=\"color: #fbde2d;\">=<\/span> lowByte(<span style=\"color: #8da6ce;\">x<\/span>); <span style=\"color: #aeaeae;\">\/\/ \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442<\/span>\r\n\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(hi);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(low);\r\n\r\n  <span style=\"color: #8da6ce;\">int<\/span> y <span style=\"color: #fbde2d;\">=<\/span> (hi&lt;&lt;<span style=\"color: #d8fa3c;\">8<\/span>)<span style=\"color: #fbde2d;\">+<\/span>low; <span style=\"color: #aeaeae;\">\/\/ \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u0438\u0437 2-\u0445 \u0431\u0430\u0439\u0442\u043e\u0432<\/span>\r\n  <span style=\"color: #aeaeae;\">\/\/ y = hi *256 + low <\/span>\r\n\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(y);\r\n} \r\n\r\n<span style=\"color: #8da6ce;\">void<\/span> loop(){}\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43166\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/745698769826348.png\" alt=\"\" width=\"189\" height=\"131\" \/><\/p>\n<div id=\"marketWidget\"><\/div>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u0431\u0430\u0439\u0442\u044b \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <strong>unsigned long<\/strong>\u00a0\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c:<\/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\r\n  unsigned long <span style=\"color: #8da6ce;\">x<\/span> <span style=\"color: #fbde2d;\">=<\/span> <span style=\"color: #d8fa3c;\">100000000<\/span>; <span style=\"color: #aeaeae;\">\/\/ \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 4 \u0431\u0430\u0439\u0442\u0430 (\u043c\u0430\u043a\u0441. 4,294,967,295)<\/span>\r\n  uint8_t x0 <span style=\"color: #fbde2d;\">=<\/span> ((<span style=\"color: #8da6ce;\">x<\/span> &gt;&gt; <span style=\"color: #d8fa3c;\">0<\/span>) <span style=\"color: #fbde2d;\">&amp;<\/span> <span style=\"color: #d8fa3c;\">0xFF<\/span>);  <span style=\"color: #aeaeae;\">\/\/ 00 00 00 FF<\/span>\r\n  uint16_t x1 <span style=\"color: #fbde2d;\">=<\/span> ((<span style=\"color: #8da6ce;\">x<\/span> &gt;&gt; <span style=\"color: #d8fa3c;\">8<\/span>) <span style=\"color: #fbde2d;\">&amp;<\/span> <span style=\"color: #d8fa3c;\">0xFF<\/span>); <span style=\"color: #aeaeae;\">\/\/ 00 00 FF 00<\/span>\r\n  uint32_t x2 <span style=\"color: #fbde2d;\">=<\/span> ((<span style=\"color: #8da6ce;\">x<\/span> &gt;&gt; <span style=\"color: #d8fa3c;\">16<\/span>) <span style=\"color: #fbde2d;\">&amp;<\/span> <span style=\"color: #d8fa3c;\">0xFF<\/span>);<span style=\"color: #aeaeae;\">\/\/ 00 FF 00 00<\/span>\r\n  uint32_t x3 <span style=\"color: #fbde2d;\">=<\/span> ((<span style=\"color: #8da6ce;\">x<\/span> &gt;&gt; <span style=\"color: #d8fa3c;\">24<\/span>) <span style=\"color: #fbde2d;\">&amp;<\/span> <span style=\"color: #d8fa3c;\">0xFF<\/span>);<span style=\"color: #aeaeae;\">\/\/ FF 00 00 00<\/span>\r\n\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(x0);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(x1);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(x2);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n  Serial.<span style=\"color: #8da6ce;\">print<\/span>(x3);\r\n\r\nunsigned long y <span style=\"color: #fbde2d;\">=<\/span> (x3 &lt;&lt; <span style=\"color: #d8fa3c;\">24<\/span>) <span style=\"color: #fbde2d;\">+<\/span> (x2 &lt;&lt; <span style=\"color: #d8fa3c;\">16<\/span>) <span style=\"color: #fbde2d;\">+<\/span> (x1 &lt;&lt; <span style=\"color: #d8fa3c;\">8<\/span>) <span style=\"color: #fbde2d;\">+<\/span> x0; <span style=\"color: #aeaeae;\">\/\/ \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u0438\u0437 4-\u0445 \u0431\u0430\u0439\u0442\u043e\u0432<\/span>\r\n  \r\n    Serial.<span style=\"color: #8da6ce;\">print<\/span>(<span style=\"color: #61ce3c;\">\" \"<\/span>);\r\n    Serial.<span style=\"color: #8da6ce;\">print<\/span>(y);\r\n} \r\n\r\n<span style=\"color: #8da6ce;\">void<\/span> loop(){\r\n}\r\n\r\n<\/pre>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43167\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/972567346439827.png\" alt=\"\" width=\"234\" height=\"126\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/972567346439827.png 234w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2018\/06\/972567346439827-200x108.png 200w\" sizes=\"auto, (max-width: 234px) 100vw, 234px\" \/><\/p>\n<table style=\"height: 110px;\" width=\"729\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\">int8_t<\/td>\n<td style=\"text-align: center;\">char<\/td>\n<td style=\"text-align: center;\">\u00a0<span style=\"text-align: center;\">\u043e\u0442 -128 \u0434\u043e 127<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">uint8_t<\/td>\n<td style=\"text-align: center;\">byte,\u00a0unsigned\u00a0char<\/td>\n<td style=\"text-align: center;\">\u00a0 \u043e\u0442 0 \u0434\u043e 255<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">int16_t<\/td>\n<td style=\"text-align: center;\">int<\/td>\n<td style=\"text-align: center;\">\u043e\u0442 -32768 \u0434\u043e 32767<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">uint16_t<\/td>\n<td style=\"text-align: center;\">unsigned int, word<\/td>\n<td style=\"text-align: center;\">\u00a0\u043e\u0442 0 \u0434\u043e 65535<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">int32_t<\/td>\n<td style=\"text-align: center;\">long<\/td>\n<td style=\"text-align: center;\">\u043e\u0442 \u00a0-2147483648 \u0434\u043e 2147483647<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">uint32_t<\/td>\n<td style=\"text-align: center;\">unsigned long<\/td>\n<td style=\"text-align: center;\">\u043e\u0442 0 \u0434\u043e 4294967295<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 highByte() \u0438 lowByte() \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0438 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0430\u0439\u0442 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 int. \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043a\u0430\u043a int, \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u0431\u0430\u0439\u0442\u0430\u0445. \u0424\u0443\u043d\u043a\u0446\u0438\u044f lowByte() \u0434\u0430\u0441\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 highByte() &#8212; \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0430\u0439\u0442\u0430. \u041f\u0440\u0438\u043c\u0435\u0440: void setup(){ Serial.begin(9600); long x = 10000; \/\/ \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e &gt; 255 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u043d\u0430 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239],"tags":[],"class_list":["post-43165","post","type-post","status-publish","format-standard","hentry","category-arduino"],"views":8008,"_links":{"self":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43165","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=43165"}],"version-history":[{"count":4,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43165\/revisions"}],"predecessor-version":[{"id":111571,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/43165\/revisions\/111571"}],"wp:attachment":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=43165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=43165"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=43165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}