<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Bluetooth commands don't move the servo]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1727&amp;type=atom" />
	<updated>2024-02-19T08:38:07Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1727</id>
		<entry>
			<title type="html"><![CDATA[Re: Bluetooth commands don't move the servo]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5354#p5354" />
			<content type="html"><![CDATA[<p>hey<br />seem like issue lies with servo pin assignment. Check whether the servo library is initialized properly or not.?</p>]]></content>
			<author>
				<name><![CDATA[hailey67]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2603</uri>
			</author>
			<updated>2024-02-19T08:38:07Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5354#p5354</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Bluetooth commands don't move the servo]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=5274#p5274" />
			<content type="html"><![CDATA[<p>hi guys, I&#039;m trying to set up a simple application to be able to control a servomotor through the esp32 via an on and off switch. The servo motor should move from 0 to 180 degrees and back in a loop while the switch is on, and stop when the switch is off. the problem is that the servomotor doesn&#039;t move. <br />The connections with the wires are correct because I tried to move it by commanding it from the PC and it works; at the same time, the bluetooth connection also works, because I tried to print on the serial monitor the bluetooth commands that I send from the phone to the board and it was succesfull. what could be the problem at this point? Thank you!</p><br /><br /><br /><p>//////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; RemoteXY include library&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />//////////////////////////////////////////////</p><p>// RemoteXY select connection mode and include library <br />#define REMOTEXY_MODE__ESP32CORE_BLE<br />#include &lt;BLEDevice.h&gt;<br />#include &lt;ESP32Servo.h&gt;<br />#include &lt;RemoteXY.h&gt;</p><p>// RemoteXY connection settings <br />#define REMOTEXY_BLUETOOTH_NAME &quot;RemoteXY&quot;</p><br /><p>// RemoteXY configurate&nbsp; <br />#pragma pack(push, 1)<br />uint8_t RemoteXY_CONF[] =&nbsp; &nbsp;// 27 bytes<br />&nbsp; { 255,1,0,0,0,20,0,16,16,1,2,0,18,39,30,13,4,27,31,31,<br />&nbsp; 79,78,0,79,70,70,0 };<br />&nbsp; <br />// this structure defines all the variables and events of your control interface <br />struct {</p><p>&nbsp; &nbsp; // input variables<br />&nbsp; uint8_t switch_1; // =1 if switch ON and =0 if OFF </p><p>&nbsp; &nbsp; // other variable<br />&nbsp; uint8_t connect_flag;&nbsp; // =1 if wire connected, else =0 </p><p>} RemoteXY;<br />#pragma pack(pop)</p><p>/////////////////////////////////////////////<br />//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END RemoteXY include&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //<br />/////////////////////////////////////////////</p><p>#define PIN_SWITCH_1 18<br />Servo myServo;<br />int servoPin = 18;</p><br /><p>void setup() <br />{<br />&nbsp; &nbsp;Serial.begin(9600);&nbsp; // Inizializza la comunicazione seriale<br />&nbsp; RemoteXY_Init (); <br />&nbsp; myServo.attach(servoPin);<br />&nbsp; pinMode (PIN_SWITCH_1, OUTPUT);<br />&nbsp; <br />}</p><br /><br /><p>void loop() <br />{ <br />&nbsp; RemoteXY_Handler ();<br />&nbsp; <br />&nbsp; digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);<br />&nbsp; <br />&nbsp; // Check the switch state<br />&nbsp; if (RemoteXY.switch_1 == 1) {<br />&nbsp; &nbsp; // If the switch is ON, activate the servo motor<br />&nbsp; &nbsp; &nbsp;Serial.println(&quot;Switch is ON. Moving the servo...&quot;);<br />&nbsp; &nbsp; &nbsp; Serial.println(&quot;Moving the servo...&quot;);<br />&nbsp; // Move the servo only if the switch is ON<br />for (int angle = 0; angle &lt;= 180; angle++) {<br />&nbsp; &nbsp; myServo.write(angle);<br />&nbsp; &nbsp; Serial.println(&quot;Angle: &quot; + String(angle));&nbsp; // Stampa il valore di angle<br />&nbsp; &nbsp; RemoteXY_delay(3);<br />}</p><p>for (int angle = 180; angle &gt;= 0; angle--) {<br />&nbsp; &nbsp; myServo.write(angle);<br />&nbsp; &nbsp; Serial.println(&quot;Angle: &quot; + String(angle));&nbsp; // Stampa il valore di angle<br />&nbsp; &nbsp; RemoteXY_delay(3);<br />}</p><br /><p>} else {<br />&nbsp; &nbsp; // If the switch is OFF, stop the servo motor<br />&nbsp; &nbsp; myServo.write(90); // Assuming 90 is the center position<br />&nbsp; &nbsp; Serial.println(&quot;Switch is OFF. Stopping the servo.&quot;);<br />&nbsp; &nbsp; RemoteXY_delay(300); // Aggiungi un ritardo dopo aver posizionato il servo<br />}<br />}</p>]]></content>
			<author>
				<name><![CDATA[l_k_k]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2614</uri>
			</author>
			<updated>2023-12-13T14:13:51Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=5274#p5274</id>
		</entry>
</feed>
