# Title: Help Needed with Arduino Uno Project: Motor Control Issue

**URL:** <https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971>\
**Category:** General Guidance\
**Created:** [March 28, 2024, 9:36am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971 "2024-03-28T09:36:22Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 9:36am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/1 "2024-03-28T09:36:22Z")

</div>

**Title: Help Needed with Arduino Uno Project: Motor Control Issue**

**Hello Everyone,**

I hope you're all doing well. I'm reaching out to seek some assistance with a project I've been working on involving an Arduino Uno and a motor control setup.

**Project Overview:**

- **Components:** Arduino Uno, L293D motor driver, TT gear motors (4x), 7.4V lithium-ion battery.
- **Objective:** Control the movement of a car using the Arduino and Bluetooth module.
- **Issue:** Despite extensive troubleshooting, the motors are not responding to control commands.

**Problem Details:**

- I've wired the components according to the circuit diagram provided in the project documentation.
- The Arduino code has been uploaded without errors, and the Bluetooth module is successfully paired with my smartphone.
- When sending control commands ('F' for forward, 'B' for backward, etc.) via the Bluetooth module, the motors do not respond.
- I've checked the power supply voltage and current, and they seem to be within the required range for the motors and motor driver.

**What I've Tried:**

- Double-checked all connections and wiring.
- Tested the motors individually to ensure they're functional.
- Verified the Arduino code for any logical errors or issues.
- Used debug print statements to monitor the behavior of the code and components.
- Reviewed the datasheets and documentation for each component to ensure correct usage.

**Seeking Assistance:** Despite my efforts, I haven't been able to identify the root cause of the issue. If anyone has experience with similar projects or expertise in troubleshooting Arduino and motor control setups, I would greatly appreciate any insights or suggestions you can provide.

**Additional Information:**

- I can provide more detailed information, including the circuit diagram, Arduino code, and any other relevant details upon request.
- Any guidance or advice you can offer would be immensely helpful and greatly appreciated.

Thank you in advance for your time and assistance. I'm eager to overcome this obstacle and complete my project successfully.

Best regards,  
Khushit

Here is the code

```arduino

  Arduino Bluetooth Controlled Car
  Install Adafruit Motor Shield Library before uploading this code.
  AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install

  -> If you need helping guide on how to install library for the motor shield or how to use motor shield then
     watch this: https://youtu.be/vooJEyco1J4

     Caution: Remove the jumper or switch off the battery switch before connecting the Arduino board to computer.

     For more support contact me on Telegram: @UtGoTech

*/

#include <AFMotor.h>
#include <SoftwareSerial.h>

SoftwareSerial bluetoothSerial(9, 10); // RX, TX

//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);

char command;

void setup()
{
  bluetoothSerial.begin(9600); //Set the baud rate to your Bluetooth module.
}

void loop() {
  if (bluetoothSerial.available() > 0) {
    command = bluetoothSerial.read();

    Stop(); //initialize with motors stoped
    
    switch (command) {
      case 'F':
        forward();
        break;
      case 'B':
        back();
        break;
      case 'L':
        left();
        break;
      case 'R':
        right();
        break;
    }
  }
}

void forward()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(FORWARD); //rotate the motor clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(BACKWARD); //rotate the motor anti-clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(FORWARD); //rotate the motor clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(FORWARD); //rotate the motor clockwise
}

void right()
{
  motor1.setSpeed(255); //Define maximum velocity
  motor1.run(FORWARD); //rotate the motor clockwise
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
  motor4.setSpeed(255); //Define maximum velocity
  motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void Stop()
{
  motor1.setSpeed(0); //Define minimum velocity
  motor1.run(RELEASE); //stop the motor when release the button
  motor2.setSpeed(0); //Define minimum velocity
  motor2.run(RELEASE); //rotate the motor clockwise
  motor3.setSpeed(0); //Define minimum velocity
  motor3.run(RELEASE); //stop the motor when release the button
  motor4.setSpeed(0); //Define minimum velocity
  motor4.run(RELEASE); //stop the motor when release the button
}

```

circuit diagram

 ![Bluetooth RC Car Connection Diagram](https://europe1.discourse-cdn.com/arduino/original/4X/f/b/0/fb0757250c3595d8db99d2cf20c862481e8637ae.png)

---

<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:** [March 28, 2024, 9:45am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/2 "2024-03-28T09:45:53Z")

</div>

Welcome to the forum

Start by printing the command received via Bluetooth. You will need to add the Serial,begin() command in setup()

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 10:02am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/3 "2024-03-28T10:02:10Z")

</div>

i got lost can you change the part of code if possible

---

<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:** [March 28, 2024, 10:14am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/4 "2024-03-28T10:14:52Z")

</div>

Add

```arduino
Serial.begin(115200);

```

to setup()

Add

```arduino
Serial.println(command);

```

after you read the value of command and before you call the Stop() function in loop()

Open the Serial monitor and set its baud rate to 115200. What do you seen in the Serial monitor ?

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 10:59am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/5 "2024-03-28T10:59:08Z")

</div>

as soon i send control to go forward serial monitor displays F  
F  
and as soon as i stop sending command it shows S. so hc 05

---

<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:** [March 28, 2024, 11:59am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/6 "2024-03-28T11:59:02Z")

</div>

Do you mean that when you send a single F it prints F then prints F again on the next line ?

What is sending the commands and is it sending anything anything after the command character ?

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 12:11pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/7 "2024-03-28T12:11:45Z")

</div>

yes F on another line if i hold the button and S if i do not press any button and printing nothing after F

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 12:15pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/8 "2024-03-28T12:15:13Z")

</div>

i even gave arduino another power supply amd l293d another supply. so i dissconeted the power pins from l293d. in short only the analog pins a1 a2 a3 a4 a5 and pins 1 2 3 4 5 6 7 8 9 12 13 so no connection of power between l293d and arduino

---

<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:** [March 28, 2024, 12:21pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/9 "2024-03-28T12:21:33Z")

</div>

I suspect that there are problems in the code that controls the car and/or the circuit or power to the motors but there is obviously something wrong with the data being received as well

The second F on a newline indicates that at least a Newline character is being received and possibly a Carriage Return as well. Receiving an S is also a mystery because according to you nothing is being sent

What exactly is sending the commands ? You refer to a button but what does that button control ?

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 12:26pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/10 "2024-03-28T12:26:37Z")

</div>

S means stop so I use a app which has 4 controls left right forward backward. Whenever I click forward button it sends F. As soon i stop pressing any button maybe the app automatically sends Stop command. Maybe there might be error in app because as I click F within milliseconds the app sends S

---

<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:** [March 28, 2024, 12:42pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/11 "2024-03-28T12:42:49Z")

</div>

Your code always stops the motors if **any** character is received and that includes the S and any line ending characters

Comment out the call to Stop() after reading the command

---

<div class="post-metadata">

**Author:** ![hallowed31](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hallowed31/32/1093680_2.png) [@hallowed31](https://forum.arduino.cc/u/hallowed31)\
**Post date:** [March 28, 2024, 3:25pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/12 "2024-03-28T15:25:36Z")

</div>

> [@khushit\_shah](#):
>
> `https://youtu.be/vooJEyco1J4`

Are you sure the Adafruit board you're using today is the 1.2 Motor Shield? That product is discontinued acc to Adafruit and the youtube you're following is three years old.

Adafruit links to this if yours is the 2.0 shield

[https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-dc-motors](https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-dc-motors)

You'll need to install different libraries if so then try a couple of their example sketches to see if you get any action. I've always found Adafruit's own tutorials to be among the best out there, if you haven't already, I'd look through there

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 28, 2024, 3:53pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/13 "2024-03-28T15:53:05Z")

</div>

On the first try 2 months ago I made it but only 3 motors were moving so I rebuilded the whole project but after rebuilding no motors were moving with same code. I bought 4 shields because I thought I fryed all boards. But after trying it with all boards still not moving. So how do I identify which version it is or which library to use

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [March 28, 2024, 8:03pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/14 "2024-03-28T20:03:10Z")

</div>

> [@khushit\_shah](#):
>
> no motors were moving with same code

This could be your bluetooth function not passing the information to make your motors run... but verify your motors first...

Verify each motor is working by using the battery with each motor.

- connecting battery(plus) to motor(plus)
- touch battery(minus) to motor(minus)
- the motor should be running at top speed in one direction.
- exchange B+ and B-
- the motor should run "backward" from the first test.

If all your motors work, next step is communicating with the Motor Driver board.

On this link to a forum page, search for the "MOTORS" section. You will find ten motor tests that should work through your shield if you can address the Arduino DIO/PWM pins connected to your motors. The first eight tests focus on one motor at a time. Test 9 and 10 will exercise two motors at a time, in both directions, at varying speeds.

> [@LAFVIN 2WD Smart Robot Car Kit V2.2](https://forum.arduino.cc/t/lafvin-2wd-smart-robot-car-kit-v2-2-updating/1235599):
>
> In this topic I will be posting links, drawings, sketches and observations to operate or isolate problems particular to the Lafvin 2WD V2.2 kit which uses the TB6612FNG (NOT the L298N) motor controller and the JDY-16 Bluetooth module - the other devices are common digital and analog sensors (IR remote/receiver, IR proximity sensor, line tracker, SG90 servo, HC-SR04, LDR/photoresistors). Best thing to start with, LAFVIN Contact Us page if the following information does not solve your problem; …

---

<div class="post-metadata">

**Author:** ![khushit\_shah](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@khushit\_shah](https://forum.arduino.cc/u/khushit_shah)\
**Post date:** [March 29, 2024, 6:53am UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/15 "2024-03-29T06:53:04Z")

</div>

tried it but still same issue I even tried using different libraries but the issues persists. motors are working

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [March 29, 2024, 2:26pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/16 "2024-03-29T14:26:57Z")

</div>

> [@khushit\_shah](#):
>
> tried it same issue

Please, explain what you tried, and what you observed. "it" made no mention of a library. Also "it" included direct battery-to-motor. Is your battery the right size, not charged, did the motors run at full speed? Reverse?

---

<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:** [September 25, 2024, 2:27pm UTC](https://forum.arduino.cc/t/title-help-needed-with-arduino-uno-project-motor-control-issue/1240971/17 "2024-09-25T14:27:51Z")

</div>

Closed on September 25, 2024, 2:27pm UTC

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