I dont know how to solve this problem

I have several problems, but dont know how to solve. please help me
error
motor_control:120:7: error: expected ';' before 'break'
break;
^~~~~
motor_control:136:18: error: 'distance' was not declared in this scope
Serial.println(distance);
^~~~~~~~
C:\Users\CHOLAB\Desktop\motor_control\motor_control.ino:136:18: note: suggested alternative: 'isSpace'
Serial.println(distance);
^~~~~~~~
isSpace
exit status 1
expected ';' before 'break'

Here is code

#define echo 2
#define trig 3
//Define pin numbers

//right motor
int m1f = 11;
int m1f_in1 = 12;
int m1f_in2 = 13;

//left motor
int m2f = 6;
int m2f_in1 = 7;
int m2f_in2 = 5;

char value;
int val[3];
int len;
int direc;

void setup()
{
//start serial communication at Baud rate of 9600
Serial.begin(9600);
pinMode(m1f, OUTPUT);
pinMode(m2f, OUTPUT);
pinMode(m1f_in1, OUTPUT);
pinMode(m1f_in2, OUTPUT);
pinMode(m2f_in1, OUTPUT);
pinMode(m2f_in2, OUTPUT);
pinMode(trig, OUTPUT); // trig 출력 설정
pinMode(echo, INPUT); // echo 입력 설정
}

void execute()
{
int no;
int i = 0;
float distance, duration;

duration = pulseIn(echo, HIGH);
distance = ((float)(340*duration) / 10000) / 2;

//convert ASCII value from serial buffer into int
no = value - '0';
//Serial.println(no);

int a, c;

/*
"""
Direction control Index:
'<' , '>' are the frame check bits for serial communication
Numbers represent the direction to be moved as per their position on numpad
4: Left
5: Stay still
6: Right
7: Front Left
8: Forward
9: Forward right
"""
*/

switch (no)
{

case 4:
  a = 255; c = 255;
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, LOW); 
  digitalWrite(m2f_in1, LOW); 
  digitalWrite(m2f_in2, HIGH);
  break;
case 5:
  a = 0; c = 0;
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, HIGH); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, HIGH);
  break;
case 6:
  a = 255; c = 255; 
  digitalWrite(m1f_in1, LOW); 
  digitalWrite(m1f_in2, HIGH); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, LOW); 
  break;
case 7:
  a = 255; c = 100; 
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, LOW); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, LOW); 
  break;
case 8:{
if(distance >= 200)
  {
  a = 150; c = 150;
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, LOW); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, LOW); 
  }
else{
  a = 0; c = 0; 
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, HIGH); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, HIGH);
  }
  break;
}
case 9:
  a = 100; c = 255; 
  digitalWrite(m1f_in1, HIGH); 
  digitalWrite(m1f_in2, LOW); 
  digitalWrite(m2f_in1, HIGH); 
  digitalWrite(m2f_in2, LOW); 1
  break;

}

analogWrite(m1f, a);
analogWrite(m2f, c);

//delay(255);
}

void loop()
{

digitalWrite(trig, HIGH);
delay(10);
digitalWrite(trig, LOW);

Serial.println(distance);
if (Serial.available())
{
//Check for frame control bits
char ch = Serial.read();
if (ch == '<')
{
len = 0;
}
else if (ch == '>')
{
execute();
//Serial.println(value);
len = 1;
}
else if (len == 0)
value = ch;
}
}

In the first error, there is semi-colon, but the error happened again, so I dont know how to solve

float distance, duration;

Are these global or local variables ?

Does the code actually have the "1" at the end of the line preceding break; ?

Hello and good morning
The Arduino IDE comiler is a nice guy. He tells you that an error occur in line 138 position 18.
Check it.

The variable distance is defined as local to the function execute() so is not known in the loop().
Fix also the problem highlighted in post #3

for posting future versions of your code use this method
You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

it assures that a single code-section is created

the compiler writes a lot of lines in the outputwindow.
To find those lines that tell the "coordinates" of the error search for
": error:"

doublepoint a space and then "error:"

not ":error:"

: error:

right  : error:
wrong  :error:

best regards Stefan

Hi, @koreanddanggul
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will make your code appear in its own scrolling window, this will make reading your code easier.

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