Need Help! Wiring and code for arduino firetruck

Hi,
I'm creating an Arduino controlled firetruck that needs to move forwards, backwards and shoot water. I had finished the circuit and uploaded the code however when I was trying to control it via the app Dabble it didn't work. Could anyone give me any help?
Here's the circuit diagram:


And I used the code from this website:
https://create.arduino.cc/projecthub/theSTEMpedia/4-wheel-robot-made-with-arduino-controlled-using-dabble-4650f7
Additional info: I'm using 9v currently, using a Bluetooth module called XC4382 BLE Bluetooth Module, I'm trying to use the controlling app called Dabble.

Any help will be greatly appreciated, thanks.

This is a joke? Right?

No, it isn't. I'm a beginner sorry.

Hi,
These 9V batteries are not able to supply current to turn motors and bluethoot transmitter.
You will need to use either AAA batteries, but the recommended for this type of project are LI-ION batteries.

Is This your battery?

PP3

Okay, thank you! I'll try AAA batteries with voltage above 9v :slight_smile:

Have you done something simple using this Dabble thing?

Like turning on and off some LEDs?

a7

Hello bellr16
Post your sketch, well formated, with comments and in so called code tags "</>" to see how we can help.
Have a nice day and enjoy coding in C++.

#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#define INCLUDE_DABBLEINPUTS_MODULE
#include <Dabble.h>

#define motor1_en 10
#define motor2_en 11
#define motor1_dir1 4
#define motor1_dir2 5
#define motor2_dir1 6
#define motor2_dir2 7

// connect bluetooth 
//  Tx --> 0
//  Rx --> 1

void setup() 
    {
       // put your setup code here, to run once:
       Serial.begin(250000);
       Dabble.begin(9600);  

       for(unsigned int i=4;i<8;i++)
         {
             pinMode(i,OUTPUT);
         }
         pinMode(motor1_en,OUTPUT);
         pinMode(motor2_en,OUTPUT);

       
        
    }

void loop() 
     {
        // put your main code here, to run repeatedly:
        Dabble.processInput();
        if (GamePad.isUpPressed())
          {
            Serial.print("UP");
            forward();
          }

        else if (GamePad.isDownPressed())
          {
             Serial.print("DOWN");
             backward();
          }

       else  if (GamePad.isLeftPressed())
           {
              Serial.print("Left");
              left();
           }

       else  if (GamePad.isRightPressed())
           {
               Serial.print("Right");
               right();
           }

           else 
           {
            Serial.println("strop");
            Stop();
           }


     }

     void forward()
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,HIGH);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,HIGH);
        digitalWrite(motor2_dir2,LOW);
      
     }
     void backward()
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,HIGH);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,HIGH);
      
     }
     void left()
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,HIGH);
        digitalWrite(motor2_dir1,HIGH);
        digitalWrite(motor2_dir2,LOW);
      
     }
     void right()
     {
        analogWrite(motor1_en,255);
        analogWrite(motor2_en,255);
        digitalWrite(motor1_dir1,HIGH);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,HIGH);
      
     }
     void Stop()
     {
        analogWrite(motor1_en,0);
        analogWrite(motor2_en,0);
        digitalWrite(motor1_dir1,LOW);
        digitalWrite(motor1_dir2,LOW);
        digitalWrite(motor2_dir1,LOW);
        digitalWrite(motor2_dir2,LOW);
      
     }

Hello bellr16
Check the wiring and run a simple tutorial for the Dabble interface.

Yes, I have done that and I have been able to connect the Bluetooth module to the app! I just need to change my code. I'm however confused by this statement "swap out our motor driver code inside of our conditional statements and replace it with yours". Could anyone tell me what that means?

Hi, I was wondering if I could please get some guidance.
I am making a fire truck with an Arduino Uno using 12V. I'm using the motor shield that goes on top of the Arduino, hobby motors/wheels, a Bluetooth module to control via an app called Dabble, a small submersible pump, and a pant and tilt servo motor set up.

So far I am able to control the wheels and pump, however, I am unable to control the servo motors. I was previously having an issue where the Arduino would heat up (due to the servo motors) so I installed a recommended DC-DC Stepdown module. I have installed the Stepdown module and double-checked my code, but the servo motors still don't work correctly.
I am a newbie to code and these kinds of projects, so I was wondering if someone could double-check my code.
Thanks.

#include <Servo.h>
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2); 
AF_DCMotor motor3(3);
Servo horzServo; // Create a servo object for the pan (horizontal) servo
Servo vertServo; // Create a servo object for the tilt (vertical) servo
int angle1 = 90;
int angle2 = 0;

void setup() {
    //Set initial speed of the motor & stop
  motor1.setSpeed(50); 
  motor2.setSpeed(50); 
  motor3.setSpeed(125);   //At 50 it was 6.5V. 
  motor1.run(RELEASE); 
  motor2.run(RELEASE); 
  motor3.run(RELEASE);
  horzServo.attach(9); // Use pin 9 PWM output for horizontal servo
  vertServo.attach(10); // Use pin 10 PWM output for vertical servo 
  horzServo.write(angle1);
  vertServo.write(angle2);
  Serial.begin(9600);    // Set your Serial Monitor is set at 250000
  Dabble.begin(9600);      // This is the baude rate of the HM-10
}

void loop() {
Dabble.processInput();  // This line is crucial in grabbing our data  
  uint8_t i;
  if (GamePad.isUpPressed())       
  {
    Serial.println("Forward");

  // Turn on motor
  motor1.run(FORWARD); 
  motor2.run(FORWARD);
  
  // Accelerate from zero to maximum speed
  for (i=0; i<50; i++) 
  {
    motor1.setSpeed(i);
    delay(0);
    motor2.setSpeed(i);  
    delay(0);
  }

  }else if (GamePad.isDownPressed())
  {
    Serial.println("Backward");
    
  // Now change motor direction
  motor1.run(BACKWARD); 
  motor2.run(BACKWARD);
  
  // Accelerate from zero to maximum speed
  for (i=0; i<50; i++) 
  {
    motor1.setSpeed(i); 
    delay(0);
    motor2.setSpeed(i);
    delay(0);
  }
  }else if (GamePad. isLeftPressed())
  {
    Serial.println("Stopped");
  // Now turn off motor
  motor1.run(RELEASE); 
  delay(10);
  motor2.run(RELEASE);
  delay(10);
  }
  if (GamePad. isCirclePressed())
  {
    Serial.println("Start");
   // On Water Pump
   motor3.run(FORWARD);
   delay(0);
  }
  if (GamePad. isCrossPressed())
  {
    Serial.println("Stop");
   // Off Water Pump
   motor3.run(RELEASE);
   delay(10);
  }
  if (GamePad. isTrianglePressed())
  {
  angle1 -= 5;
  horzServo.write(angle1);
  delay(1000);
  }
  if (GamePad. isSquarePressed())
  {
  angle1 += 5;
  horzServo.write(angle1);
  delay(1000);
  }
  if (GamePad. isSelectPressed())
  {
  angle2 -= 5;
  horzServo.write(angle2);
  delay(1000);
  }
  if (GamePad. isRightPressed())
  {
  angle2 += 5;
  horzServo.write(angle2);
  delay(1000);
  }
}

Which pins are the motors controlled by ?

The servo motors have been put on the top of the motor shield as they have a designated area but it's pin 9 and pin 10.

Hi,
Can you please post a circuit diagram, showing ALL your power supplies, component names and pin labels.
A hand drawn image would be fine, a Fritzy would not.

Have you got the servo power supply gnd connected to the UNO gnd?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:
PS. Have you written code that JUST runs the servos, to prove you can control them?

Are you saying that there are both motors and Servos connected to pins 9 and 10 ?

I have also noticed a mistake in my code where I didn't write vertServo in the last two sections of code!!!
This seemed to help but the Arduino is still getting hot. Is this normal?

What specifically is getting hot ?

No, only the servo motors. Servo one to pin 9. Servo two to pin 10. The motors of the wheels are connected to motors 1 and 2 on the motor shield.

Underneath the Arduino where the motor 1 and 2 are connected