Arduino Car Issue Halp! Please

Hello, I have a group of students that have made a miniature battle bot car and followed directions from the following video.

The problem that they've run into is that with everything connected only one motor will run at a time. If they remove a pin off of the A or B motor driver board and plug it into the 5V behind it the other motor will turn in and vice versa.

They arn't allowed to use a lithium battery so they are utilizing 6 AA batteries.

Any ideas or solutions would be amazing please :smiley:

Welcome to the forum

Much more detail is required

Please post the sketch here, using code tags when you do. In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Please post a schematic of the project showing all of its components, how they are connected and how they are powered. A 'photo of a hand drawn circuit is good enough

1 Like

Video not viewable.

Is the joystick centered, or is its output interfering with which motor is being used?

I will take a SWAG and suggest you measure the battery voltage when running no, 1, 2 motors and let us know what you get. Sorry you did not supply enough information to determine what you have much less what the problem is.

Apologies, I am very new to all of this. I have attached the ino file and will get the voltage readings shortly. I am a middle school teacher and my student is in a MESA competition that only allows their bot to be 750grams. Lithium batteries are not allowed so we are using AA batteries currently we have 6 connected to the motor driver and 6 connected to the arduino.

ArduinoRcCarFlysky (2).ino (2.4 KB)

You'll get a lot more help if the code is posted here...

// Arduino RC Car using Flysky Transmitter and Receiver
// Subscribe the Channel: https://www.YouTube.com/@AKElectroDIY
// Video Link: https://youtu.be/q-Clw0m3E18

int enA = 5;
int in1 = 2;
int in2 = 3;
int enB = 6;
int in3 = 4;
int in4 = 7;

int receiver_pins[] = {A0, A1, A2, A3, A4, A5};
int receiver_values[] = {0, 0, 0, 0, 0, 0};
int res_min = 950;
int res_max = 2020;

int working_range = 255; // motor driver range

boolean prt = true;

int mode = 0;
//-1 = transmitter not connected or out of range
// 0 = transmitter connected and ready
// 1 = slow speed mode
// 2 = high speed mode

void setup() {
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);

  Serial.begin(115200);
}

void loop() {
  receive();

  int m1 = 0;
  int m2 = 0;

  int rot = receiver_values[0];

  if (mode == 1) {
    m1 = receiver_values[1] / 2 + (rot) / 1.5;
    m2 = receiver_values[1] / 2 - (rot) / 1.5;

  } else if (mode == 2) {

    m1 = receiver_values[1] + rot / 1.75;
    m2 = receiver_values[1] - rot / 1.75;
  }

  mpower(1,  m1);
  mpower(2,  m2);
}

int rp = 0;

void receive() {
  receiver_values[rp] = map(pulseIn (receiver_pins[rp], HIGH), res_min, res_max, -1 * working_range, working_range);
  rp++;
  if (rp == 6) {
    rp = 0;
  }
  boolean activevalues = true;
  for (int i = 0; i < 6; i++) {
    if (prt) {
      Serial.print("CH");
      Serial.print(i);
      Serial.print(" : ");
      Serial.print(receiver_values[i]);
      Serial.print(",\t");
    }
    if (receiver_values[i] < -500) {
      activevalues = false;
    }
  }
  mode = 0;
  if (!activevalues) {
    mode = -1;
  } else if (receiver_values[4] > -100) {
    mode = 2;
  } else if (receiver_values[5] > -100) {
    mode = 1;
  }
  if (prt) {
    Serial.println("");
  }
}

void mpower(int motor,  int spd) {
  int rotation = 0;
  if (spd > 0) {
    rotation = 1;
  } else if (spd < 0) {
    rotation = -1;
    spd *= -1;
  }
  if (spd > 255) {
    spd = 255;
  }
  int pwm;
  int pA;
  int pB;
  if (motor == 1) {
    pwm = enA;
    pA = in1;
    pB = in2;
  } else if (motor == 2) {
    pwm = enB;
    pA = in3;
    pB = in4;
  } else {
    return;
  }
  if (rotation == 0) {
    digitalWrite(pA, LOW);
    digitalWrite(pB, LOW);
  } else if (rotation == 1) {
    digitalWrite(pA, HIGH);
    digitalWrite(pB, LOW);
  } else if (rotation == -1) {
    digitalWrite(pA, LOW);
    digitalWrite(pB, HIGH);
  }
  analogWrite(pwm, spd);
}

Sorry.. :frowning:
Voltage
when checking the 12v / GND I get 12.2v
Output A and B both get 4.5 with the 5v jumper plugged in

Without the 5v pin the board doesn't turn on.

If i put a pin in the 5v power supply and reroute it back into the 12v the voltage continues to rise non stop The board turns back on and both wheels will activate slowly. Output A and B Fluctuate between 10 and 20

Where is 12.2V coming from? Your battery pack is around 9V.

Its coming from the battery pack, I am sorry I didn't realize I swapped it out with an 8 AA pack I was going back and forth testing them....

Ok, we all make mistakes.

So, we are still waiting for the schematic that was requested in post #2.

Good question. Are they using the exact same Flysky tx and rx? The one in the video link shows a model aircraft type where the left stick doesn't auto center.

Lots of times for a bot such as this, you may find it easier to use the one stick only, the right one (elevator and aileron) and mix the channels in the radio settings themselves to get what you need. You can play around with this live, just get the wheels off the ground by placing the bot on a soup can or something like a stand.

Sorry had class :frowning: I believe this is what your asking for. I am using the exact same receiver and transmitter from the video. I followed his directions to change channels and set switches to control the wheels.

A very big difference between the video and your schematic is that they used 3 1860 lithium batteries AND they they have 2 sets of leads comming off the battery pack. One set goes to the driver board, the other goes to the barrel input of the Uno. This means that GND and +VCC (in their case 3.7 x 3 = 11.1V) are tied together. In your configuration, they are not. At the very least, you should have the ground wires tied together so you have a common ground throughout your entire system.

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