I need help with a few errors on arduino uno code

this is the error i am getting
`

C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino: In function 'void setup()':
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:39:9: error: initializer provided for function
         (Serial.println("Inside stopcar()"));
         ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino: At global scope:
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:50:9: error: initializer provided for function
         (Serial.println("Inside  forward()");
         ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:52:22: error: expected ')' before '(' token
         (digitalWrite(ENA,HIGH));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:53:22: error: expected ')' before '(' token
         (digitalWrite(ENB,HIGH));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:54:22: error: expected ')' before '(' token
         (digitalWrite(IN1,LOW));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:55:22: error: expected ')' before '(' token
         (digitalWrite(IN2,HIGH));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:56:22: error: expected ')' before '(' token
         (digitalWrite(IN3,LOW));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:57:22: error: expected ')' before '(' token
         (digitalWrite(IN4,HIGH));
                      ^
C:\Users\Sumeet Gupta\AppData\Local\Temp\.arduinoIDE-unsaved202473-24692-mn85fj.6c2bs\sketch_aug3a\sketch_aug3a.ino:58:3: error: expected declaration before '}' token
   }
   ^

exit status 1

Compilation error: initializer provided for function

Welcome to the forum

Do you think it might be helpful if you posted your code ?

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.

You missed a un-needed parenthesis when you wrote

(Serial.println("Inside  forward()");

as the closing parenthesis is the one for the function call Serial.println and you don't have the one for the initial opening parenthesis

why are all those statements with parenthesis anyway? it's not needed

don't write

 (Serial.println("Inside stopcar()"));

just

Serial.println("Inside stopcar()");
1 Like

A few examples:

Serial.println("Hello");  // okay
Serial.println("Inside stopcar()");  // okay
(Serial.println("Hello")); // not okay
(Serial.println("Inside stopcar()"));  // not okay
(Serial.println("Hello")); // not okay
(Serial.println("Inside stopcar()"));  // not okay

Unconventional, I agree, but OK in the right context, which we don't have

1 Like

your "not ok" examples

are actually grammatically correct in C++

missing the closing parenthesis would be not OK (

(Serial.println("Hello"); // not okay
(Serial.println("Inside stopcar()");  // not okay
1 Like

Syntactically ok; but, it an illierate way of coding.

Looks like it was happening here, too. Instead, do

digitalWrite(ENB,HIGH);

and so on.
Plus, on top of the corrections others have already made to

Serial.println("Inside stopcar()");

Level up your game by using the F macro when Serial printing text, especially if you have a lot of it. It puts the text Strings into the larger flash memory space, saving you RAM which you have a lot less of (32k bytes vs 2k bytes).

Serial.println(F("Inside stopcar()"));