{"id":283141,"date":"2016-12-27T22:40:04","date_gmt":"2016-12-27T19:40:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283141"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283141","title":{"rendered":"DIY \u0434\u0438\u0441\u043a\u043e\u0442\u0435\u0447\u043d\u0430\u044f \u043b\u0430\u0437\u0435\u0440\u043d\u0430\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438\u0437 \u0443\u043a\u0430\u0437\u043a\u0438 \u0438 \u0430\u0440\u0434\u0443\u0438\u043d\u043a\u0438"},"content":{"rendered":"<p>\u0414\u043b\u044f \u0442\u0430\u043d\u0446\u0435\u0432\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0435\u0439 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043b\u0430\u0437\u0435\u0440\u043d\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u0432 \u0442\u0430\u043a\u0442 \u043c\u0443\u0437\u044b\u043a\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430. \u041f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u0431\u044b\u043b\u0430 \u043b\u0430\u0437\u0435\u0440\u043d\u0430\u044f \u0443\u043a\u0430\u0437\u043a\u0430 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0441\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043a\u043e\u043b\u043f\u0430\u0447\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043d\u0430 \u043f\u043e\u0442\u043e\u043b\u043a\u0435. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u0430\u0440\u0443 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u043e\u0432 \u0438 arduino mini pro \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u0441\u043a\u043e\u043c\u043e\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4fd\/d94\/776\/4fdd9477686543c3bd775b31cfa824ae.JPG\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u0421\u0445\u0435\u043c\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f (\u043e\u0434\u0438\u043d \u043a\u043b\u044e\u0447, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0439 \u0443\u043a\u0430\u0437\u043a\u043e\u0439; \u043f\u0430\u0440\u0430 \u043a\u0440\u0435\u043c\u043d\u0438\u0435\u0432\u044b\u0445 \u0434\u0438\u043e\u0434\u043e\u0432, \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u043a\u0438; \u0440\u0435\u0437\u0438\u0441\u0442\u043e\u0440 \u0434\u043b\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0438\u043a\u0440\u043e\u0444\u043e\u043d\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c DC-DC \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u043e\u0442 \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0430 \u0432 \u043f\u044f\u0442\u044c \u0432\u043e\u043b\u044c\u0442), \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u043c\u0430\u043a\u0435\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u044b.<\/p>\n<p>  \u041c\u0438\u043a\u0440\u043e\u0444\u043e\u043d \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u2014 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0443\u044e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0442\u0430\u043a \u0447\u0442\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a9f\/0ec\/865\/a9f0ec865dd54b82bdeea877b8e86a7a.png\"\/><\/p>\n<p>  \u041d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u0430\u0437\u0435\u0440\u043d\u043e\u0439 \u0443\u043a\u0430\u0437\u043a\u043e\u0439 \u2014 \u043e\u043d \u0443 \u043c\u0435\u043d\u044f \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f (\u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d), \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043a\u0438\u043d\u0443\u0442\u044c. \u041d\u0443 \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u043e\u0440\u0433\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c \u0441 \u0440\u0435\u0434\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0434\u043b\u044f \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043f\u0430\u0447\u043a\u0430 (\u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u043e\u0433\u043e \u0434\u0440\u043e\u0436\u0430\u043d\u0438\u044f), \u043d\u043e \u0441 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0449\u0435 (\u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u043b \u043f\u0430\u0440\u0443 \u0448\u0435\u0441\u0442\u0435\u0440\u0435\u043d\u043e\u043a \u043d\u0430 \u043f\u0440\u0438\u043d\u0442\u0435\u0440\u0435 \u0438 \u0432\u0441\u0435).<\/p>\n<p>  \u0421\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u044b \u2014 Turnigy TGY-R5180MG (180 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0434\u043b\u044f \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u043f\u0430\u0447\u043a\u0430) \u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0441\u0442\u0430\u0440\u0430\u044f 9 \u0433\u0440\u0430\u043c\u043c\u043e\u0432\u0430\u044f \u0441\u0435\u0440\u0432\u0430 (\u0434\u043b\u044f \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430). \u041f\u043e\u0434\u0441\u0442\u0430\u0432\u043a\u0430 \u2014 \u0442\u0440\u0435\u043d\u043e\u0436\u043d\u0438\u043a \u043e\u0442 \u0432\u0435\u043d\u0442\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 hobbyking \u043f\u0440\u043e\u0434\u0430\u0432\u0430\u043b\u0430 \u043a\u0430\u043a-\u0442\u043e \u0437\u0430 \u043a\u043e\u043f\u0435\u0439\u043a\u0438.<\/p>\n<p>  \u0412\u0438\u0434\u0435\u043e \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0px; width: 100%; height: 0px; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/aA_EWn9h2MY?rel=0&amp;showinfo=1\" frameborder=\"0\" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0421\u043a\u0435\u0442\u0447:<\/p>\n<pre><code>#include &lt;Servo.h&gt;  \/\/ yaw servo - PWM #define SERVO_YAW 5 \/\/ roll servo - PWM #define SERVO_ROLL 6 \/\/ Laser pin - PWM or DO #define LASER 9  \/\/ Microphone input - A0 #define MIC A0  \/\/ Yaw servo period (in ms) #define YAW_PERIOD 40  \/\/ Roll servo period (in ms) #define ROLL_PERIOD 100  \/\/ MIN value for yaw servo #define MIN_YAW 40 \/\/ MAX value for yaw servo #define MAX_YAW 130 \/\/ MIN value for roll servo #define MIN_ROLL 10 \/\/ MAX value for roll servo #define MAX_ROLL 150  Servo yaw_servo; Servo roll_servo;  \/\/ Current position and direction for servos int16_t roll_pos = MIN_ROLL; int8_t roll_dir = 1; int16_t yaw_pos = MIN_YAW; int8_t yaw_dir = 1;  \/\/ Sound peak detected boolean flag_sound = false;  \/\/ Internal sound volume average stuff int16_t arr_vol[32]; int8_t arr_pos = 0;  unsigned long last_sound = 0;  \/\/ Detect sound volume peaks void check_sound() {   int16_t volume = analogRead(MIC);   int i;   int32_t sum;   int16_t average;    \/\/ Calculate average from last reads   arr_vol[arr_pos] = volume;   arr_pos++;   if (arr_pos &gt; (sizeof(arr_vol) \/ sizeof(arr_vol[0])))     arr_pos = 0;   sum = 0;   for (i = 0; i &lt; (sizeof(arr_vol) \/ sizeof(arr_vol[0])); i++)     sum += arr_vol[i];   average = sum \/ (sizeof(arr_vol) \/ sizeof(arr_vol[0]));    if (flag_sound && ((millis() - last_sound) &gt; 200))     flag_sound = false;   if ((millis() - last_sound) &lt; 300)     return;   if (volume &gt; (average + 4)) {     flag_sound = true;     last_sound = millis();   } } \/\/ void check_sound()  unsigned long last_yaw = 0;  \/\/ Rotate yaw servo void rotate_yaw() {   if ((millis() - last_yaw) &lt; YAW_PERIOD)     return;   last_yaw = millis();   yaw_pos += yaw_dir;   \/\/ Change rotate direction when reached limit   if ((yaw_pos &gt;= MAX_YAW) || (yaw_pos &lt;= MIN_YAW))     yaw_dir = -yaw_dir;   yaw_servo.write(yaw_pos); } \/\/ void rotate_yaw()   unsigned long last_roll = 0;  \/\/ Rotate roll servo void rotate_roll() {   if ((millis() - last_roll) &lt; ROLL_PERIOD)     return;   last_roll = millis();   roll_pos += roll_dir;    \/\/ Rotate faster when we detect sound peaks   if (flag_sound) {     roll_pos += (8 * roll_dir);     if (roll_pos &lt; MIN_ROLL)       roll_pos = MIN_ROLL;     if (roll_pos &gt; MAX_ROLL)       roll_pos = MAX_ROLL;   }      \/\/ Change rotate direction when reached limit   if ((roll_pos &gt;= MAX_ROLL) || (roll_pos &lt;= MIN_ROLL))     roll_dir = -roll_dir;   roll_servo.write(roll_pos); } \/\/ void rotate_roll()  void setup() {   \/\/ put your setup code here, to run once:   pinMode(LASER, OUTPUT);   digitalWrite(LASER, HIGH);    yaw_servo.attach(SERVO_YAW);   yaw_servo.write(yaw_pos);   roll_servo.attach(SERVO_ROLL);   roll_servo.write(roll_pos);      Serial.begin(115200);   delay(300); } \/\/ void setup()  void loop() {   \/\/ put your main code here, to run repeatedly:    check_sound();   rotate_yaw();   rotate_roll();    delay(10); } \/\/ void loop()<\/code><\/pre>\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=\"https:\/\/geektimes.ru\/post\/284146\/\"> https:\/\/geektimes.ru\/post\/284146\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043b\u044f \u0442\u0430\u043d\u0446\u0435\u0432\u0430\u043b\u044c\u043d\u043e\u0439 \u043d\u043e\u0432\u043e\u0433\u043e\u0434\u043d\u0435\u0439 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043b\u0430\u0437\u0435\u0440\u043d\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u0432 \u0442\u0430\u043a\u0442 \u043c\u0443\u0437\u044b\u043a\u0435 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0430. \u041f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u0431\u044b\u043b\u0430 \u043b\u0430\u0437\u0435\u0440\u043d\u0430\u044f \u0443\u043a\u0430\u0437\u043a\u0430 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0441\u043c\u0435\u043d\u043d\u044b\u0445 \u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043a\u043e\u043b\u043f\u0430\u0447\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u0438\u043c\u043f\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b \u043d\u0430 \u043f\u043e\u0442\u043e\u043b\u043a\u0435. \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u0430\u0440\u0443 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u043e\u0432 \u0438 arduino mini pro \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u0441\u043a\u043e\u043c\u043e\u0435.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4fd\/d94\/776\/4fdd9477686543c3bd775b31cfa824ae.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-283141","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283141","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=283141"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283141\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}