Error when I upload

Error(sketch_jul14c:13:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(m1, OUTPUT);
^
sketch_jul14c:14:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(m2, OUTPUT);
^
sketch_jul14c:15:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(m3, OUTPUT);
^
sketch_jul14c:16:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(m4, OUTPUT);
^
sketch_jul14c:17:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(e1, OUTPUT);
^
sketch_jul14c:18:8: error: expected constructor, destructor, or type conversion before '(' token
pinMode(e2, OUTPUT);
^
sketch_jul14c:19:1: error: 'Serial' does not name a type
Serial.begin(9600);
^~~~~~
/Users/wkm/Documents/Arduino/sketch_jul14c/sketch_jul14c.ino: In function 'void loop()':
sketch_jul14c:27:5: error: expected ';' before 'if'
if (serialData == '1') {
^~
sketch_jul14c:31:5: error: 'Reverse' was not declared in this scope
Reverse motion of car else if (serialData == '2') {
^~~~~~~
sketch_jul14c:36:3: error: 'else' without a previous 'if'
else if (serialData == '3') {
^~~~
sketch_jul14c:37:5: error: 'Motor' was not declared in this scope
Motor set 1 digitalWrite(m1, 0); digitalWrite(m2, 0);
^~~~~
sketch_jul14c:38:11: error: expected ';' before 'set'
Motor set 2 digitalWrite(m3, 0); digitalWrite(m4, 0);
^~~
sketch_jul14c:43:3: error: expected ';' before 'else'
else if (serialData == '4') {
^~~~
sketch_jul14c:47:3: error: 'else' without a previous 'if'
else if (serialData == '5') {
^~~~
sketch_jul14c:48:5: error: 'x' was not declared in this scope
x = 150;
^
sketch_jul14c:52:5: error: 'x' was not declared in this scope
x = 255;
^
sketch_jul14c:56:5: error: 'Motor' was not declared in this scope
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 1); digitalWrite(m2, 0); //Motor set 2 analogWrite(e2, x); digitalWrite(m4, 0); digitalWrite(m3, 1);
^~~~~
sketch_jul14c:60:5: error: 'Motor' was not declared in this scope
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 0); digitalWrite(m2, 1); //Motor set 2 analogWrite(e2, x); digitalWrite(m4, 1); digitalWrite(m3, 0);
^~~~~
exit status 1
expected constructor, destructor, or type conversion before '(' token
)
That's my code
//Declare variables
char serialData;
//Declaring Pins of arduino to pins of Deek robot 2 Channel motor driver (L293D)
//Play around your driver to control the direction of motors
int m1 = 8; //connects to IN2 pin of Deek Robot motor driver -->Sets the direction
int m2 = 4; //Connects to IN1 pin of Deek Robot motor driver --> Sets the direc- tion
int e1 = 9; //Connects to EN1 pin of Deek Robot motor driver -->Sets the speed
int m3 = 7; //connects to IN3 pin of Deek Robot motor driver -->Sets the direc- tion
int m4 = 2; //Connects to IN4 pin of Deek Robot motor driver -->Sets the direc- tion
int e2 = 6; //Connects to EN2 pin of Deek Robot motor driver -->Sets the speed int x =0; //Variable to store the speed value from Python
//Setup your baudrate & arduino pins void setup()

pinMode(m1, OUTPUT);
pinMode(m2, OUTPUT);
pinMode(m3, OUTPUT);
pinMode(m4, OUTPUT);
pinMode(e1, OUTPUT);
pinMode(e2, OUTPUT);
Serial.begin(9600);

void loop() {
// send data only when you receive data from python if (Serial.available() > 0)
{
serialData = Serial.read(); Serial.print(serialData);
128
//Forward motion of car
if (serialData == '1') {
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 1); digitalWrite(m2, 0);
Motor set 2 analogWrite(e2, x); digitalWrite(m4, 1); digitalWrite(m3, 0);
}
Reverse motion of car else if (serialData == '2') {
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 0); digitalWrite(m2, 1);
Motor set 2 analogWrite(e2, x); digitalWrite(m4, 0); digitalWrite(m3, 1);
}
//Apply brakes
else if (serialData == '3') {
Motor set 1 digitalWrite(m1, 0); digitalWrite(m2, 0);
Motor set 2 digitalWrite(m3, 0); digitalWrite(m4, 0);
}
129

//set Speed level 1
else if (serialData == '4') {
x = 80;
}
//set Speed level 2
else if (serialData == '5') {
x = 150;
}
//set Speed level 3
else if (serialData == '6') {
x = 255;
}
//Turn left
else if (serialData == '7') {
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 1); digitalWrite(m2, 0); //Motor set 2 analogWrite(e2, x); digitalWrite(m4, 0); digitalWrite(m3, 1);
}
//Turn right
else if (serialData == '8') {
Motor set 1 analogWrite(e1, x); digitalWrite(m1, 0); digitalWrite(m2, 1); //Motor set 2 analogWrite(e2, x); digitalWrite(m4, 1); digitalWrite(m3, 0);
}
}
}

Did you miss out a comment?

// Motor set 1 
digitalWrite(m1, 0);
//Setup your baudrate & arduino pins void setup()

sp.

void setup ()
 {

Please remember to use code tags when posting code

@wkmk, your topic has been moved to a more suitable location on the forum. This is not an upload error but a compiler error.

Please edit your post

  1. select all error information and click the </> button to apply code tags
  2. select all code and click the </> button to apply code tags
  3. save your post

Next spend some time reading How to get the best out of this forum (again?) where the use of code tags is explained.

Code tags make it easier to read your code and to copy code.

That should be:

int e2 = 6; //Connects to EN2 pin of Deek Robot motor driver -->Sets the speed 
int x =0; //Variable to store the speed value from Python
//Setup your baudrate & arduino pins 
void setup()
{
  pinMode(m1, OUTPUT);
  pinMode(m2, OUTPUT);
  pinMode(m3, OUTPUT);
  pinMode(m4, OUTPUT);
  pinMode(e1, OUTPUT);
  pinMode(e2, OUTPUT);
  Serial.begin(9600);
}

void loop() {

Thanks for all I am new