<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — Помогите пожалуста. Как сделать плавный поворот серво?]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=1820</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1820&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Помогите пожалуста. Как сделать плавный поворот серво?.]]></description>
		<lastBuildDate>Fri, 14 Jun 2024 07:45:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Помогите пожалуста. Как сделать плавный поворот серво?]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5583#p5583</link>
			<description><![CDATA[<p>Здравствуйте, никак не могу заставить серво вращаться плавно.<br />Написал вот такой код:</p><br /><p>#include &lt;Servo.h&gt;</p><p>/*<br />&nbsp; &nbsp;-- New project1 --<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;This source code of graphical user interface <br />&nbsp; &nbsp;has been generated automatically by RemoteXY editor.<br />&nbsp; &nbsp;To compile this code using RemoteXY library 3.1.13 or later version <br />&nbsp; &nbsp;download by link <a target="_blank" href="http://remotexy.com/en/library/">http://remotexy.com/en/library/</a><br />&nbsp; &nbsp;To connect using RemoteXY mobile app by link <a target="_blank" href="http://remotexy.com/en/download/">http://remotexy.com/en/download/</a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;- for ANDROID 4.13.13 or later version;<br />&nbsp; &nbsp; &nbsp;- for iOS 1.10.3 or later version;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp;This source code is free software; you can redistribute it and/or<br />&nbsp; &nbsp;modify it under the terms of the GNU Lesser General Public<br />&nbsp; &nbsp;License as published by the Free Software Foundation; either<br />&nbsp; &nbsp;version 2.1 of the License, or (at your option) any later version.&nbsp; &nbsp; <br />*/</p><p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////</p><p>// можете включить вывод отладочной информации в Serial на 115200<br />//#define REMOTEXY__DEBUGLOG&nbsp; &nbsp; </p><p>// определение режима соединения и подключение библиотеки RemoteXY <br />#define REMOTEXY_MODE__HARDSERIAL</p><br /><p>// настройки соединения <br />#define REMOTEXY_SERIAL Serial<br />#define REMOTEXY_SERIAL_SPEED 9600</p><br /><p>#include &lt;RemoteXY.h&gt;</p><p>// конфигурация интерфейса RemoteXY&nbsp; <br />#pragma pack(push, 1)&nbsp; <br />uint8_t RemoteXY_CONF[] =&nbsp; &nbsp;// 45 bytes<br />&nbsp; { 255,2,0,0,0,38,0,17,0,0,0,13,2,106,200,200,84,1,1,2,<br />&nbsp; 0,4,16,22,27,81,17,53,78,14,176,94,26,4,18,152,73,24,150,2,<br />&nbsp; 17,71,0,37,26 };<br />&nbsp; <br />// структура определяет все переменные и события вашего интерфейса управления <br />struct {</p><p>&nbsp; &nbsp; // input variables<br />&nbsp; int8_t slider_01; // oт -100 до 100<br />&nbsp; int8_t slider_02; // oт 0 до 100</p><p>&nbsp; &nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0</p><p>} RemoteXY;&nbsp; &nbsp;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////</p><p>Servo myservo;<br />Servo motor1;<br />void setup() <br />{<br />&nbsp; RemoteXY_Init (); <br />&nbsp; myservo.attach(3);<br />&nbsp; motor1.attach(2);<br />&nbsp; motor1.writeMicroseconds(1500);<br />&nbsp; delay(2000);<br />&nbsp; motor1.writeMicroseconds(800);<br />&nbsp; delay(6000);</p><br /><br /><p>&nbsp; // TODO you setup code<br />&nbsp; <br />}</p><p>void loop() <br />{ <br />&nbsp; RemoteXY_Handler ();<br />&nbsp; <br />&nbsp; for (int x = map(RemoteXY.slider_01, -100, 100, 0, 180); x &lt;= 180; x++){<br />&nbsp; &nbsp; myservo.write(x);<br />&nbsp; &nbsp; RemoteXY_delay(10);<br />&nbsp; }<br />&nbsp; for (int x = map(RemoteXY.slider_01, -100, 100, 0, 180); x &gt;= 0; x--){<br />&nbsp; &nbsp; myservo.write(x);<br />&nbsp; &nbsp; RemoteXY_delay(10);}</p><p>&nbsp; <br />&nbsp; <br />&nbsp; // TODO you loop code<br />&nbsp; // используйте структуру RemoteXY для передачи данных<br />&nbsp; // не используйте функцию delay(), вместо нее используйте RemoteXY_delay() <br />&nbsp; //int x = map(RemoteXY.slider_01, -100, 100, 0, 180);<br />&nbsp; //myservo.write(x);<br />&nbsp; //RemoteXY_delay(1);<br />&nbsp; <br />&nbsp; int val = map(RemoteXY.slider_02, 0, 100, 800, 1500);<br />&nbsp; motor1.writeMicroseconds(val);</p><p>}<br />Но с таким кодом серво поварачивается самопроизвольно. Помогите исправить код или подскажите новый пожалуйста.</p>]]></description>
			<author><![CDATA[null@example.com (Айдар)]]></author>
			<pubDate>Fri, 14 Jun 2024 07:45:53 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5583#p5583</guid>
		</item>
	</channel>
</rss>
