Arduino obstacle avoiding robot problem code

hi to all guys, I’m building a robot that avoids obstacles, but I have a problem with the code. I did not write myself, I found it was ready for a robot in 2wd, mine is a 4wd. I can not add other engines. I get an error in the code. Could you help? thanks a lot!

“APC_4_ROBOT.ino: In function ‘void checkForward ()’:
APC_4_ROBOT: 109: error: a function-definition is not allowed here before ‘{’ token
APC_4_ROBOT: 180: error: expected `} 'at end of input”

APC_4_ROBOT.ino (10.1 KB)

You can' t add the brackets in these lines:

//-------------------------------------------------------------------------------------------------------------------------------------
void checkForward() { if (motorSet=="FORWARD") {motor1.run(FORWARD); motor2.run(FORWARD); {motor3.run(FORWARD); motor4.run(FORWARD); } }     // make sure motors are going forward
//-------------------------------------------------------------------------------------------------------------------------------------
void checkBackward() { if (motorSet=="BACKWARD") {motor1.run(BACKWARD); motor2.run(BACKWARD); {motor3.run(BACKWARD); motor4.run(BACKWARD); } } // make sure motors are going backward
//-------------------------------------------------------------------------------------------------------------------------------------

These lines must be:

//-------------------------------------------------------------------------------------------------------------------------------------
void checkForward() { if (motorSet=="FORWARD") {motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD); } }     // make sure motors are going forward
//-------------------------------------------------------------------------------------------------------------------------------------
void checkBackward() { if (motorSet=="BACKWARD") {motor1.run(BACKWARD); motor2.run(BACKWARD); motor3.run(BACKWARD); motor4.run(BACKWARD); } } // make sure motors are going backward
//-------------------------------------------------------------------------------------------------------------------------------------

Thanks a lot now it works, I can ask you another question?
When the robot is connected to the USB PC and powered by 4 AAA batteries work, if the ex-usb and leave only the battery stops. What power is it for? thanks a lot!

It can be because the motor are powered only by the batteries. What kind of robot it is?

something like this: Robot

I mounted the motor shield and I connected the power supply. 4 AAA batteries. Even I have to feed the Arduino? it is as if he had enough power, and does not move

Even I have to feed the Arduino?

Yes. The Arduino likes Kibbles and Bits, three times a day.

Sorry I'm Italian and I do not speak English very well .. However, I have to use the Arduino to 9v and 9v to the motor shield?

In the picture you attached at your post, I can see that the Arduino UNO is powered by the battery pack. Can you confirm that yours is different?

mine is powered by the battery pack, attached to the motor shied. The LED turn on but does not move.

hello, Real quick question. I am also working on a very similar project, and I'm very new at programming. So, my question is; if I'm going to use only two motors I would just delete the Motor 3 and motor 4 functions, right?
Thanks in advance!

if I’m going to use only two motors I would just delete the Motor 3 and motor 4 functions, right?

Yes.

Please help me making my code ..
if anyone having coding experience plss help me
i Am Using HC SR-04
Tower pro micro servo
futaba s3003 x2 hacking for continous roatation
arduino uno
9 v battery for arduino
4.8 v battery for ardiuno.......

Starting a new thread might be a better idea. With a clear description of your problem.

i dont know coding ... i have made the hardware i i want a complete code for my robot.
if you want i can send you pictures