# Bluetooth module delay

**URL:** <https://forum.arduino.cc/t/bluetooth-module-delay/1073661>\
**Category:** Programming\
**Created:** [January 5, 2023, 4:12pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661 "2023-01-05T16:12:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![scorpion258](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@scorpion258](https://forum.arduino.cc/u/scorpion258)\
**Post date:** [January 5, 2023, 4:12pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661/1 "2023-01-05T16:12:27Z")

</div>

Hello im building arduino car for my science project, and i have quite big delay when controling car trought mobile app, sometimes it works fine but other i have like 4s delay. Anybody some ideas why is it happening ? Im useing arduino UNO and HC-05 module. \<#include \<AFMotor.h\>  
#include \<SoftwareSerial.h\>  
//0,1

SoftwareSerial BTSerial (0,1); // Rx a Tx  
AF\_DCMotor Motor\_1(1); //lavy predny  
AF\_DCMotor Motor\_2(2); //lavy zadny  
AF\_DCMotor Motor\_3(3); //predny pravy  
AF\_DCMotor Motor\_4(4); //zadny pravy  
int rychlo = 250;  
int fast = 250; //M4  
int fast2 = 250;  
const int ledPin = 7;

void setup() {  
BTSerial.begin(9600);  
pinMode(ledPin, OUTPUT);  
}

void loop() {

if (BTSerial.available()) {  
char znak\_citany = BTSerial.read ();

```
switch(znak_citany) {
  case 'F':
    dopredu();
    break;
  case 'B':
    dozadu();
    break;
  case 'L':
    dolava();
    break;
  case 'R':
    doprava();
    break;
  case '1':
    dolava_hore();
    break;
  case '2':
    doprava_hore();
    break;
  case '3':
    dolava_dolu();
    break;
  case '4' :
    doprava_dolu();
    break;
  case '5':
    otocenie_doprava();
    break;
  case '6':
    otocenie_dolava();
    break;
  case 'S':
    zastavenie();
    break;
  case 'U':
    digitalWrite(ledPin, HIGH);
    break;
  case 'D' :
    digitalWrite(ledPin, LOW);
    break;
  default:
    zastavenie();
    break;
 
  }

```

}  
}

void dopredu () {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(FORWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(FORWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(FORWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(FORWARD);  
}  
void dozadu () {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(BACKWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(BACKWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(BACKWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(BACKWARD);

}

void dolava () {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(FORWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(BACKWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(FORWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(BACKWARD);  
}

void doprava () {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(BACKWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(FORWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(BACKWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(FORWARD);

}

void dolava\_hore () {  
Motor\_1.setSpeed(fast2);  
Motor\_1.run(FORWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(FORWARD);  
}

void doprava\_hore () {  
Motor\_2.setSpeed(fast2);  
Motor\_2.run(FORWARD);  
Motor\_4.setSpeed(fast);  
Motor\_4.run(FORWARD);  
}

void dolava\_dolu () {  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(BACKWARD);  
Motor\_4.setSpeed(fast);  
Motor\_4.run(BACKWARD);  
}

void doprava\_dolu () {  
Motor\_1.setSpeed(fast2);  
Motor\_1.run(BACKWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(BACKWARD);  
}

void zastavenie () {  
Motor\_1.setSpeed(0);  
Motor\_1.run(RELEASE);  
Motor\_2.setSpeed(0);  
Motor\_2.run(RELEASE);  
Motor\_3.setSpeed(0);  
Motor\_3.run(RELEASE);  
Motor\_4.setSpeed(0);  
Motor\_4.run(RELEASE);

}

void otocenie\_doprava() {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(FORWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(BACKWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(BACKWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(FORWARD);

}  
void otocenie\_dolava() {  
Motor\_1.setSpeed(rychlo);  
Motor\_1.run(BACKWARD);  
Motor\_2.setSpeed(rychlo);  
Motor\_2.run(FORWARD);  
Motor\_3.setSpeed(rychlo);  
Motor\_3.run(FORWARD);  
Motor\_4.setSpeed(rychlo);  
Motor\_4.run(BACKWARD);

}/\>

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [January 5, 2023, 4:13pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661/2 "2023-01-05T16:13:46Z")

</div>

Your topic was **MOVED** to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

---

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [January 5, 2023, 4:40pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661/3 "2023-01-05T16:40:00Z")

</div>

have a read of [how-to-get-the-best-out-of-this-forum](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966)  
for example, upload your code using code tags \</\>  
did you implement the mobile app or us2 an existing one

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [January 5, 2023, 6:11pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661/4 "2023-01-05T18:11:50Z")

</div>

Hi @scorpion258,

you are welcome in this forum. Though you violated an important rule:  
posting code **not** as a code-section

If you RE-edited your post I will answer some of the things that are problematic in your code

> [@Make experienced users help: two ways to quickly post code as a code-section](https://forum.arduino.cc/t/make-experienced-users-help-two-ways-to-quickly-post-code-as-a-code-section/937298):
>
> Hi newcomer, This thread wants to show you how you can speed-up getting helpful answers with small effort. If you manage at least to post this way. You have the sympathy of the experienced users. If you are willing to invest another 20 minutes these 20 minutes extra-time will save you a minimum of 200 minutes to finish your project. always post your full sketch. As a code-section from the very first to the very last line A code-section has a small height =\> keeps your posting "short" but e…

best regards Stefan

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 4, 2023, 6:12pm UTC](https://forum.arduino.cc/t/bluetooth-module-delay/1073661/5 "2023-07-04T18:12:20Z")

</div>

Closed on July 4, 2023, 6:12pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
