user54199: I have one problem with my code and I'm a beginner and I can't solve it. Can you help me? Thank you so much.
I have this problem:  
error: expected unqualified-id before '{' token

And this is my code: 
int trigPin = 12;
int echoPin = 11;
long timeperiod, cm;
const int analogOutPin = 9;
int brightness;

void setup()
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop(){

  if (timeperiod > 50)
  analogWrite(analogOutPin,0);
}
{

  if (timeperiod 10 < 50){
  for(brightness = 0; brightness < 256; brightness++){
    analogWrite(led,brightness);
    delay(10);}
}}
  if (timeperiod < 10)
  analogWrite(analogOutPin,0);

{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(20);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(0);
  digitalWrite(trigPin, LOW);

  timeperiod = pulseIn(echoPin, HIGH);

  cm = microsecondsToCentimeters(timeperiod);
  Serial.print("dist=");
  Serial.print(cm);
  Serial.println();

  delay(10);
}
long microsecondsToInches(long microseconds)
{ 
  return microseconds / 74 /2;
}
  long microsecondsToCentimeters(long microseconds)
{
  return microseconds / 29/ 2;
}


user54311: The only problem I can see in your code is that your code modules are starting and ending anywhere. See from where till where you want to run a particular line of code. If you writing this code on arduino IDE you will be able to see which the ending of a particular bracket when you keep the cursor on one. 

54199: <p>I have one problem with my code and I'm a beginner and I can't solve it. Can you help me? Thank you so much.</p>

<p>I have this problem:  </p>

<pre><code>error: expected unqualified-id before '{' token
</code></pre>

<p>And this is my code: </p>

<pre><code>int trigPin = 12;
int echoPin = 11;
long timeperiod, cm;
const int analogOutPin = 9;
int brightness;

void setup()
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop(){

  if (timeperiod &gt; 50)
  analogWrite(analogOutPin,0);
}
{

  if (timeperiod 10 &lt; 50){
  for(brightness = 0; brightness &lt; 256; brightness++){
    analogWrite(led,brightness);
    delay(10);}
}}
  if (timeperiod &lt; 10)
  analogWrite(analogOutPin,0);

{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(20);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(0);
  digitalWrite(trigPin, LOW);

  timeperiod = pulseIn(echoPin, HIGH);

  cm = microsecondsToCentimeters(timeperiod);
  Serial.print("dist=");
  Serial.print(cm);
  Serial.println();

  delay(10);
}
long microsecondsToInches(long microseconds)
{ 
  return microseconds / 74 /2;
}
  long microsecondsToCentimeters(long microseconds)
{
  return microseconds / 29/ 2;
}
</code></pre>
 54311: <p>The only problem I can see in your code is that your code modules are starting and ending anywhere. See from where till where you want to run a particular line of code. If you writing this code on arduino IDE you will be able to see which the ending of a particular bracket when you keep the cursor on one. </p>
