user70365: void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
if(Serial.available()>0)
{s_num =Serial.read();}
if(s_num=='0'){
digitalWrite(13,HIGH);
delay(100); //the specified time for 0
digitalWrite(13,LOW);
delay(100);}
if(s_num=='1'){
digitalWrite(13,HIGH);
delay(200);
digitalWrite(13,LOW);
delay(200);}
if(s_num=='2'){
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);}
char s_num; if(s_num=='3'){
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(400);}
if(s_num=='4'){
digitalWrite(3,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);}
if(s_num=='5'){
digitalWrite(13,HIGH);
delay(600);
digitalWrite(13,LOW);
delay(600);}
if(s_num=='6'){
digitalWrite(13,HIGH);
delay(700);
digitalWrite(13,LOW);
delay(700);}
if(s_num=='7'){
digitalWrite(13,HIGH);
delay(800);
digitalWrite(13,LOW);
delay(800);}
if(s_num=='8'){
digitalWrite(13,HIGH);
delay(900);
digitalWrite(13,LOW);
delay(900);}
if(s_num=='9'){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);}
digitalWrite(13,LOW);
s_num=10;
}


user31105: One tip to prevent these kind of error: next time align the { and } and you see the error very fast:
void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop() 
{
  char s_num; 
  if(Serial.available()>0)
  {
    s_num =Serial.read();
  }

  if(s_num=='0')
  {
    digitalWrite(13,HIGH);
    delay(100); //the specified time for 0
    digitalWrite(13,LOW);
    delay(100);
  }

  if(s_num=='1')
  {
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(200);
  }

  if(s_num=='2')
  {
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
  }
 
  if(s_num=='3')
  {
    digitalWrite(13,HIGH);
    delay(400);
    digitalWrite(13,LOW);
    delay(400);
  }
  
  if(s_num=='4')
  {
    digitalWrite(3,HIGH);
    delay(500);
    digitalWrite(13,LOW);
    delay(500);
  }

  if(s_num=='5')
  {
    digitalWrite(13,HIGH);
    delay(600);
    digitalWrite(13,LOW);
    delay(600);
  }

  if(s_num=='6')
  {
    digitalWrite(13,HIGH);
    delay(700);
    digitalWrite(13,LOW);
    delay(700);
  }
  if(s_num=='7')
  {
    digitalWrite(13,HIGH);
    delay(800);
    digitalWrite(13,LOW);
    delay(800);
  }
  if(s_num=='8')
  {
    digitalWrite(13,HIGH);
    delay(900);
    digitalWrite(13,LOW);
    delay(900);
  }
  if(s_num=='9')
  {
    digitalWrite(13,HIGH);
    delay(1000);
    digitalWrite(13,LOW);
    delay(1000);
  }
  digitalWrite(13,LOW);
  s_num=10;
}

As you can see char s_name needs to be be declared in the front of the method as you need it in the second line, so you get the following code that compiles:
void loop() 
{
  if(Serial.available()>0)
  {
    s_num =Serial.read();
  }

  if(s_num=='0')
  {
    digitalWrite(13,HIGH);
    delay(100); //the specified time for 0
    digitalWrite(13,LOW);
    delay(100);
  }

  if(s_num=='1')
  {
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(200);
  }

  if(s_num=='2')
  {
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
  }
  char s_num; 
  
  if(s_num=='3')
  {
    digitalWrite(13,HIGH);
    delay(400);
    digitalWrite(13,LOW);
    delay(400);
  }
  
  ...
}

Now you also can see that you process the s_num variable even if there is not a new value from the serial class, so you should put it probably inside, getting:
void loop() 
{
  if(Serial.available()>0)
  {
    char s_num =Serial.read();
 
    if(s_num=='0')
    {
      digitalWrite(13,HIGH);
      delay(100); //the specified time for 0
      digitalWrite(13,LOW);
      delay(100);
    }
  }
}

The last statement s_num=10; does not anything.
Now, to greatly reduce your code, all digits perform more or less the same code. You can combine this by calculating the delay time (0 -> 100, 9 -> 1000), and you get the following code:
void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop() 
{
  if (Serial.available() > 0)
  {
    char s_num = Serial.read();
    if ((s_num >= '0') && (s_num <= '9'))
    {
      uint16_t delayTime = (s_num - '0' + 1) * 100;
      digitalWrite(13, HIGH);
      delay(delayTime);
      digitalWrite(13, LOW);
      delay(delayTime);
    }
    else
    {
      digitalWrite(13, LOW);
    }
  }
}

By subtracting '0' from a character digit ('0' to '9'), you get its value.

70365: <pre><code>void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
if(Serial.available()&gt;0)
{s_num =Serial.read();}
if(s_num=='0'){
digitalWrite(13,HIGH);
delay(100); //the specified time for 0
digitalWrite(13,LOW);
delay(100);}
if(s_num=='1'){
digitalWrite(13,HIGH);
delay(200);
digitalWrite(13,LOW);
delay(200);}
if(s_num=='2'){
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);}
char s_num; if(s_num=='3'){
digitalWrite(13,HIGH);
delay(400);
digitalWrite(13,LOW);
delay(400);}
if(s_num=='4'){
digitalWrite(3,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);}
if(s_num=='5'){
digitalWrite(13,HIGH);
delay(600);
digitalWrite(13,LOW);
delay(600);}
if(s_num=='6'){
digitalWrite(13,HIGH);
delay(700);
digitalWrite(13,LOW);
delay(700);}
if(s_num=='7'){
digitalWrite(13,HIGH);
delay(800);
digitalWrite(13,LOW);
delay(800);}
if(s_num=='8'){
digitalWrite(13,HIGH);
delay(900);
digitalWrite(13,LOW);
delay(900);}
if(s_num=='9'){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);}
digitalWrite(13,LOW);
s_num=10;
}
</code></pre>
 31105: <p>One tip to prevent these kind of error: next time align the <code>{</code> and <code>}</code> and you see the error very fast:</p>
<pre><code>void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop() 
{
  char s_num; 
  if(Serial.available()&gt;0)
  {
    s_num =Serial.read();
  }

  if(s_num=='0')
  {
    digitalWrite(13,HIGH);
    delay(100); //the specified time for 0
    digitalWrite(13,LOW);
    delay(100);
  }

  if(s_num=='1')
  {
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(200);
  }

  if(s_num=='2')
  {
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
  }
 
  if(s_num=='3')
  {
    digitalWrite(13,HIGH);
    delay(400);
    digitalWrite(13,LOW);
    delay(400);
  }
  
  if(s_num=='4')
  {
    digitalWrite(3,HIGH);
    delay(500);
    digitalWrite(13,LOW);
    delay(500);
  }

  if(s_num=='5')
  {
    digitalWrite(13,HIGH);
    delay(600);
    digitalWrite(13,LOW);
    delay(600);
  }

  if(s_num=='6')
  {
    digitalWrite(13,HIGH);
    delay(700);
    digitalWrite(13,LOW);
    delay(700);
  }
  if(s_num=='7')
  {
    digitalWrite(13,HIGH);
    delay(800);
    digitalWrite(13,LOW);
    delay(800);
  }
  if(s_num=='8')
  {
    digitalWrite(13,HIGH);
    delay(900);
    digitalWrite(13,LOW);
    delay(900);
  }
  if(s_num=='9')
  {
    digitalWrite(13,HIGH);
    delay(1000);
    digitalWrite(13,LOW);
    delay(1000);
  }
  digitalWrite(13,LOW);
  s_num=10;
}
</code></pre>
<p>As you can see <code>char s_name</code> needs to be be declared in the front of the method as you need it in the second line, so you get the following code that compiles:</p>
<pre><code>void loop() 
{
  if(Serial.available()&gt;0)
  {
    s_num =Serial.read();
  }

  if(s_num=='0')
  {
    digitalWrite(13,HIGH);
    delay(100); //the specified time for 0
    digitalWrite(13,LOW);
    delay(100);
  }

  if(s_num=='1')
  {
    digitalWrite(13,HIGH);
    delay(200);
    digitalWrite(13,LOW);
    delay(200);
  }

  if(s_num=='2')
  {
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
  }
  char s_num; 
  
  if(s_num=='3')
  {
    digitalWrite(13,HIGH);
    delay(400);
    digitalWrite(13,LOW);
    delay(400);
  }
  
  ...
}
</code></pre>
<p>Now you also can see that you process the <code>s_num</code> variable even if there is not a new value from the serial class, so you should put it probably inside, getting:</p>
<pre><code>void loop() 
{
  if(Serial.available()&gt;0)
  {
    char s_num =Serial.read();
 
    if(s_num=='0')
    {
      digitalWrite(13,HIGH);
      delay(100); //the specified time for 0
      digitalWrite(13,LOW);
      delay(100);
    }
  }
}
</code></pre>
<p>The last statement <code>s_num=10;</code> does not anything.</p>
<p>Now, to greatly reduce your code, all digits perform more or less the same code. You can combine this by calculating the delay time (0 -&gt; 100, 9 -&gt; 1000), and you get the following code:</p>
<pre><code>void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop() 
{
  if (Serial.available() &gt; 0)
  {
    char s_num = Serial.read();
    if ((s_num &gt;= '0') &amp;&amp; (s_num &lt;= '9'))
    {
      uint16_t delayTime = (s_num - '0' + 1) * 100;
      digitalWrite(13, HIGH);
      delay(delayTime);
      digitalWrite(13, LOW);
      delay(delayTime);
    }
    else
    {
      digitalWrite(13, LOW);
    }
  }
}
</code></pre>
<p>By subtracting '0' from a character digit ('0' to '9'), you get its value.</p>
