This code I made for my Elegoo Smart Car isn't working properly

I was making a code for my Elegoo Smart car so the speed is not just HIGH(on) and LOW(off). The code is below:


int ENA =5;
int ENB = 6;
int IN1 = 7;
int IN2 = 8;
int IN3 = 9;
int IN4 = 11;
int speedProgress;
int speedProgressTwo;

void setup() {
Serial.begin(9600);//open serial and set the baudrate
pinMode(IN1,OUTPUT);//before useing io pin, pin mode must be set first
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
pinMode(ENA,OUTPUT);
pinMode(ENB,OUTPUT);
digitalWrite(ENA, HIGH);
digitalWrite(ENB, HIGH);
}

//Repeat execution
void loop() {
speedProgress=100;
speedProgressTwo = 100;
speedI(speedProgress,speedProgressTwo);
forward();
delay(3000);
reverse();
delay(3000);
leftTurn();
delay(3000);
rightTurn();
delay(500);

delay(10000);

}

void forward(){
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}

void rightTurn(){
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);
}

void reverse(){
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);

void leftTurn(){
digitalWrite(IN1,LOW);
digitalWrite(IN2,HIGH);
digitalWrite(IN3,LOW);
digitalWrite(IN4,HIGH);

}

void speedI(int speedProgress=100, int speedProgressTwo=100){
analogWrite(ENA,speedProgress);
analogWrite(ENB,speedProgressTwo);
}


However, whenever I compile it or try uploading it, it gives me this error message it is below.


^
speedProgressCar:69:61: error: a function-definition is not allowed here before '{' token
void speedI(int speedProgress=100, int speedProgressTwo=100){
^
speedProgressCar:72:1: error: expected '}' at end of input
}
^
exit status 1
'speedI' was not declared in this scope


Thanks

Disclaimer:
I do not own or am endorsed by Elegoo or Arduino.

Where does the function reverse end?

Please remember to use code tags when posting code

It should compile if you make two changes, see comments in all caps. The reverse function needs a curly brace and it seems the IDE forward declaration code does not work when there are default values for functions.

int ENA =5;
int ENB = 6;
int IN1 = 7;
int IN2 = 8;
int IN3 = 9;
int IN4 = 11;
int speedProgress;
int speedProgressTwo;

void setup() {
  Serial.begin(9600);//open serial and set the baudrate
  pinMode(IN1,OUTPUT);//before useing io pin, pin mode must be set first
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);
  pinMode(ENA,OUTPUT);
  pinMode(ENB,OUTPUT);
  digitalWrite(ENA, HIGH);
  digitalWrite(ENB, HIGH);
}

// *************** MOVE TO BEFORE CALL
void speedI(int speedProgress=100, int speedProgressTwo=100){
  analogWrite(ENA,speedProgress);
  analogWrite(ENB,speedProgressTwo);
}

//Repeat execution
void loop() {
  speedProgress=100;
  speedProgressTwo = 100;
  speedI(speedProgress,speedProgressTwo);
  forward();
  delay(3000);
  reverse();
  delay(3000);
  leftTurn();
  delay(3000);
  rightTurn();
  delay(500);

  delay(10000);
 
}

void forward(){
  digitalWrite(IN1,HIGH);
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,LOW);
  digitalWrite(IN3,HIGH);
  digitalWrite(IN4,LOW);
}

void rightTurn(){
  digitalWrite(IN1,HIGH);
  digitalWrite(IN2,LOW);
  digitalWrite(IN3,HIGH);
  digitalWrite(IN4,LOW);
}

void reverse(){
  digitalWrite(IN1,LOW);
  digitalWrite(IN2,HIGH);
  digitalWrite(IN3,LOW);
  digitalWrite(IN4,HIGH);
}                           // *************** ADDED CURLY BRACE

void leftTurn(){
  digitalWrite(IN1,LOW);
  digitalWrite(IN2,HIGH);
  digitalWrite(IN3,LOW);
  digitalWrite(IN4,HIGH);
 
}