<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Response problem with bluetooth - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/response-problem-with-bluetooth/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 01:25:48 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Response problem with bluetooth</title>
                        <link>https://www.tweaking4all.com/forum/arduino/response-problem-with-bluetooth/#post-4609</link>
                        <pubDate>Sat, 07 Jan 2023 12:02:30 +0000</pubDate>
                        <description><![CDATA[Hi there!
My best guess would be that the Bluetooth code is holding it up. (and yes: using switch instead of if can have an impact indeed as well)
I&#039;d try doing the code without motor cont...]]></description>
                        <content:encoded><![CDATA[<p>Hi there!</p>
<p>My best guess would be that the Bluetooth code is holding it up. (and yes: using <strong>switch</strong> instead of <strong>if</strong> can have an impact indeed as well)</p>
<p>I'd try doing the code without motor control first. Meaning: just reading Bluetooth values, to see how "fast" this works.</p>
<p>Test1: So you could change the code to send the char to the Serial monitor first.<br />Test2: Then test again with the switch statement where you you print char to the Serial monitor.</p>
<p>If all still works fast enough then we get to the next challenge and that is that motor movement takes up too much time.<br />Since the Arduino does not support multitasking, this may be your real problem.</p>
<p>Tip: The ESP32 and ESP8266 modules are cheaper, faster! Also ... those have 2 CPU cores, so you could make use of that (but this would be much more advanced).</p>
<p> </p>
<p>Test 1:</p>
<pre contenteditable="false">void setup() {
  BTSerial.begin(9600);
  pinMode(ledPin, OUTPUT);
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {

  if (BTSerial.available()) {
    char sign = BTSerial.read ();
    //F,B,L,R,S,U,D,A,C,E,G,H,I

  Serial.println(sign);
}</pre>
<p> </p>
<p>Test 2:</p>
<pre contenteditable="false">void setup() {
  BTSerial.begin(9600);
  pinMode(ledPin, OUTPUT);
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {

  if (BTSerial.available()) {
    char sign = BTSerial.read ();
    //F,B,L,R,S,U,D,A,C,E,G,H,I

  switch(sign) {
    case 'F':
      Serial.println(sign);
      break;
    case 'B':
      Serial.println(sign);
      break;
    case 'L':
      Serial.println(sign);
      break;
    case 'R':
  
    // etc etc 
  
    default:
      Serial.println(sign);
      break;
  }
  
}</pre>
<p>Hope this helps ... 😊 </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/response-problem-with-bluetooth/#post-4609</guid>
                    </item>
				                    <item>
                        <title>Response problem with bluetooth</title>
                        <link>https://www.tweaking4all.com/forum/arduino/response-problem-with-bluetooth/#post-4606</link>
                        <pubDate>Fri, 06 Jan 2023 14:43:41 +0000</pubDate>
                        <description><![CDATA[I have a problem with controlling an Arduino car via bluetooth application in mit app inventor. If I press the button, I have to wait a second or two for the car to move, and when I want to ...]]></description>
                        <content:encoded><![CDATA[<p>I have a problem with controlling an Arduino car via bluetooth application in mit app inventor. If I press the button, I have to wait a second or two for the car to move, and when I want to stop it, it also takes some time. Can you advise me where the problem is?</p>
<p> </p>
<p>Update :</p>
<p>I tried it first with if but I changed it to switch and the response decreased. I also reconnected the bluethooth module to the arduino and it also reduced, but there is still a 2 second response.<br /><br /><br />Code :<br />```<br />#include &lt;AFMotor.h&gt; <br />#include &lt;SoftwareSerial.h&gt;<br /><br />SoftwareSerial BTSerial (0,1); // Rx a Tx<br />AF_DCMotor Motor_1(1); <br />AF_DCMotor Motor_2(2); <br />AF_DCMotor Motor_3(3); <br />AF_DCMotor Motor_4(4); <br />int fast = 250; //M4<br />const int ledPin = 7;<br /><br />void setup() {<br />BTSerial.begin(9600);<br />pinMode(ledPin, OUTPUT);<br />}<br /><br />void loop() {<br /><br />if (BTSerial.available()) {<br />char sign = BTSerial.read ();<br />//F,B,L,R,S,U,D,A,C,E,G,H,I <br /><br />switch(sign) {<br />case 'F':<br />forward_();<br />break;<br />case 'B':<br />backward_();<br />break;<br />case 'L':<br />left_();<br />break;<br />case 'R':<br />right_();<br />break;<br />case 'A':<br />high_left();<br />break;<br />case 'C':<br />high_right();<br />break;<br />case 'E':<br />down_left();<br />break;<br />case 'G' :<br />down_right();<br />break;<br />case 'H':<br />turn_right();<br />break;<br />case 'I':<br />turn_left();<br />break;<br />case 'S':<br />stopping();<br />break;<br />case 'U':<br />digitalWrite(ledPin, HIGH);<br />break;<br />case 'D' :<br />digitalWrite(ledPin, LOW);<br />break;<br />default:<br />stopping();<br />break;<br /><br />}<br /><br /><br /><br />}<br />}<br /><br />void forward_ () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(FORWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(FORWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(FORWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(FORWARD);<br />}<br />void backward_ () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(BACKWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(BACKWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(BACKWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(BACKWARD);<br /><br /><br />}<br /><br />void left_ () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(FORWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(BACKWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(FORWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(BACKWARD); <br />}<br /><br />void right_ () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(BACKWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(FORWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(BACKWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(FORWARD);<br /><br />}<br /><br />void high_left () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(FORWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(FORWARD);<br />}<br /><br />void high_right () {<br />Motor_2.setSpeed(fast); <br />Motor_2.run(FORWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(FORWARD); <br />}<br /><br /><br />void down_left () {<br />Motor_2.setSpeed(fast); <br />Motor_2.run(BACKWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(BACKWARD); <br />}<br /><br /><br />void down_right () {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(BACKWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(BACKWARD); <br />}<br /><br />void stopping () {<br />Motor_1.setSpeed(0); <br />Motor_1.run(RELEASE); <br />Motor_2.setSpeed(0); <br />Motor_2.run(RELEASE); <br />Motor_3.setSpeed(0); <br />Motor_3.run(RELEASE); <br />Motor_4.setSpeed(0); <br />Motor_4.run(RELEASE); <br /><br />}<br /><br />void turn_right() {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(FORWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(FORWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(BACKWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(BACKWARD);<br /><br />}<br />void turn_left() {<br />Motor_1.setSpeed(fast); <br />Motor_1.run(BACKWARD); <br />Motor_2.setSpeed(fast); <br />Motor_2.run(BACKWARD); <br />Motor_3.setSpeed(fast);<br />Motor_3.run(FORWARD); <br />Motor_4.setSpeed(fast);<br />Motor_4.run(FORWARD);<br /><br />}<br />```</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/response-problem-with-bluetooth/#post-4606</guid>
                    </item>
							        </channel>
        </rss>
		