Arduino robot problem

Hey! I have made a multifunction Ardino-uno robot which includes voice control obstacle avoiding and blue tooth control it's a 4 wheeler robot
I have given connections according to schematic diagram and given power supply
When I upload the code only 2 out of 4 motors were running and now only 1 motor works
And ultrasonic sensor is not working, Bluetooth gets disconnected
I have tried using the functions one by one nothing works
I need to submit my project


This is schematic

Please take the time to read How to get the best out of this forum.

Then post a reply that includes your entire sketch (enclosed in code tags), a clear and legible schematic (pen and paper is fine), and links to documentation/datasheets for all the hardware you are using, Once you have done that, people will have the necessary information to perhaps be able to help you diagnose your problem(s). At the moment, you've given us nothing to work with.

And give a thought to what category you've posted in.

@nightwing_18

I've moved your post to a better place in the forum. You posted in a sort of dead area that was set up back during the pandemic for remote learning projects. I doubt you robot question would get much traffic there since it is both off topic and out of date.

It is impossible to help you without some idea of what you have, how it's connected, and the code you are trying to use. Not all robots are identical. Just because I've seen one doesn't mean I will know how yours works.

1 Like

? where ?

1 Like

Does the test code for just the 4 wheels work well?

Usually these kits ship with a 9vdc battery OR a 2xAA battery holder.

You will need TWO power supplies...

  1. One power supply for the Arduino and peripheral devices - 5vdc... so use 4xAA (1.5vdc x 4 = 6vdc)
  2. One power supply for the motors - probably 6vdc using 4xAA but maybe 5xAA (for 7.5vdc depending on motor driver board)

Or ONE power supply of about 6vdc with a BUCK converter...

  1. One power supply feeds a buck converter which feeds the Arduino and peripherals (5vdc)
  2. And... directly from the power supply, go straight to the motor driver board (6vdc)

This youtube channel builds the Elegoo robot car with bluetooth as you describe, in three videos. His kit only had one power supply, but they are LiPo, and probably 3.7vdc each for a total of 7.4vdc (see video 1 at 31:10).


I have given connections according to this schematic

When I upload the code in Arduino only two wheels were working and when I tried another code only one motor works now
And no moment in ultrasonic sensor
How can I make 4 motors work?

At first I tried with 3 (3.7v batteries)
Then immediately I got some sort of smoke from shield
And then I replaced the holder with 2 (3.7v) batteries everything was fine
But only 1 motor is running and no moment in ultrasonic

That is called a "signal" and I believe you need a new (thing that smoked).

If You post the code maybe somebody can tell. Without code and detailed schematics nobody can tell, only make wild guesses that waste time.

2 Likes

Nope once I replaced with 2 holder battery
It working without any problem I mean two motors and ultrasonic sensor were working perfectly
Now once I changed code only one motor was working

You. Need. To. Post. Your. Code.

As others have said, nobody can realistically help you if you don't do that.

Glad that fixed it... but the original was 2-holder. Hmm.

From what, to what?

#include <AFMotor.h>
#include <NewPing.h>
#include <Servo.h>

#define TRIG_PIN A0
#define ECHO_PIN A1
#define MAX_DISTANCE 200
#define MAX_SPEED 190
#define MAX_SPEED_OFFSET 20

NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
Servo myservo;

boolean goesForward=false;
int distance = 100;
int speedSet = 0;

void setup() {

myservo.attach(10);
myservo.write(115);
delay(2000);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
}

void loop() {
int distanceR = 0;
int distanceL = 0;
delay(40);

if(distance<=15)
{
moveStop();
delay(100);
moveBackward();
delay(300);
moveStop();
delay(200);
distanceR = lookRight();
delay(200);
distanceL = lookLeft();
delay(200);

if(distanceR>=distanceL)
{
turnRight();
moveStop();
}else
{
turnLeft();
moveStop();
}
}else
{
moveForward();
}
distance = readPing();
}

int lookRight()
{
myservo.write(50);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
}

int lookLeft()
{
myservo.write(170);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
delay(100);
}

int readPing() {
delay(70);
int cm = sonar.ping_cm();
if(cm==0)
{
cm = 250;
}
return cm;
}

void moveStop() {
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}

void moveForward() {

if(!goesForward)
{
goesForward=true;
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2)
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet);
motor3.setSpeed(speedSet);
motor4.setSpeed(speedSet);
delay(5);
}
}
}

void moveBackward() {
goesForward=false;
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet +=2)
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet);
motor3.setSpeed(speedSet);
motor4.setSpeed(speedSet);
delay(5);
}
}

void turnRight() {
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
delay(500);
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}

void turnLeft() {
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
delay(500);
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
}

void voicecontrol()
{
if (Serial.available() > 0) {
value = Serial.read();
Serial.println(value);
if (value == '^') {
forward();
} else if (value == '-') {
backward();
} else if (value == '<') {
L = leftsee();
servo.write(spoint);
if (L >= 10 ) {
left();
delay(500);
Stop();
} else if (L < 10) {
Stop();
}
} else if (value == '>') {
R = rightsee();
servo.write(spoint);
if (R >= 10 ) {
right();
delay(500);
Stop();
} else if (R < 10) {
Stop();
}
} else if (value == '*') {
Stop();
}
}
}

I have tried this at first my two motors were running and next only one motor was running

I think your robot is "turning"... when the HC-SR04 sees an obstacle, the wheels are made to "turn" the robot.

Sensor not responding,wheels not Turning they are just on

See post #10.

Hi,

To add code please click this link;

Tom.... :grinning: :+1: :coffee: :australia:

1 Like

Bro now I have given for only Bluetooth control car ,the Bluetooth gets connected to mobile but the motors are not responding