Use of the delay command

Hello, I got 2 question about delays. 1.-it is good to put delay after you turn on a LED on? if yes why it is good? it is because you allow the hardware to process it? 2.-when it is good to put delay in any code and why to put it?

1) no, but it useful if you want to be able to see the LED lit up 2) almost never, unless it is very very short.

Go here and learn a short lesson that will save you trouble in the future:
http://www.gammon.com.au/forum/?id=11411

If you learn that then you can work with the sketch below that blinks led 13
while taking user input and acting on it, something you can’t do using delay()
to blink the led. It’s a nice start point to modify into other multi-task sketches.

/* Blink without Delay -- with UL fixes and User Input
 
 Turns on and off a light emitting diode(LED) connected to a digital  
 pin, without using the delay() function.  This means that other code
 can run at the same time without being interrupted by the LED code.
 
 The circuit:
 * LED attached from pin 13 to ground.
 * Note: on most Arduinos, there is already an LED on the board
 that's attached to pin 13, so no hardware is needed for this example.
 
 
 created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen
 modifed to add User-I/O as BWD2 1 Jan 2014 
 by GoForSmoke :-P
 
 This example code is in the public domain.
 
 
 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */

// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
unsigned long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
unsigned long tWait = 1000UL;           // interval at which to blink (milliseconds)
unsigned long userFactor = 100UL;

void usageMsg( void )
{
  Serial.println ( F ( __FILE__ ) );
  Serial.println( F("\nUSER CONTROL CHARS\n") );
  Serial.println( F("H to print this message.") );
  Serial.println( F("F to blink faster, less factor") );
  Serial.println( F("S to blink slower, more factor") );
  Serial.println( F("digit x factor = blink\n") );
}

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);

  Serial.begin( 57600 ); 
  Serial.println( F("\nBWD2 startup\n") );
  usageMsg(); 
}

void loop()
{
  // check to see if it's time to blink the LED; that is, if the 
  // difference between the current time and last time you blinked 
  // the LED is bigger than the interval at which you want to 
  // blink the LED.
  unsigned long currentMillis = millis();

  if ( currentMillis - previousMillis > tWait ) 
  {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    ledState = !ledState; // ! is logical not, opposite

      // set the LED with the ledState of the variable:
    digitalWrite( ledPin, ledState );
  } // end of blink state change

    //    lowest priority is serial data because it is slow.
  if ( Serial.available() )
  {
    char  serChar = Serial.read();

    if ( serChar >= '0' && serChar <= '9' ) // digits only
    {
      if ( serChar > '0' )
      {
        tWait = (long)( serChar - '0' ) * userFactor;
      }
      else
      {
        tWait = 10UL * userFactor;
      }
      Serial.print( F( "wait = " ));
      Serial.println( tWait );
    } 
    else
    {
      serChar &= 0xDF; // strips bit 5, makes lowercase alphas uppercase
      if ( serChar == 'F' ) // faster
      {
        if ( userFactor > 1UL )
        {
          userFactor /= 2UL; // increase the frequency
          tWait /= 2UL;
        }
        Serial.print( F("faster factor = ") );
        Serial.println( userFactor );
        Serial.print( F("wait = ") );
        Serial.println( tWait );
      }

      if ( serChar == 'S' )  // slower
      {
        if ( userFactor < 1000UL )
        {
          userFactor *= 2UL;  // decrease the frequency
          tWait *= 2UL;
        }
        Serial.print( F("slower factor = ") );
        Serial.println( userFactor );
        Serial.print( F("wait = ") );
        Serial.println( tWait );
      }

      if ( serChar == 'H' )  // help
      {
        usageMsg();
      }
    }
  } // end of serial available

  //    finished all tasks  
}
if ( currentMillis - previousMillis > tWait ) 
  {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;

Oh so close.

AWOL: if ( currentMillis - previousMillis > tWait )   {     // save the last time you blinked the LED     previousMillis = currentMillis;

Oh so close.

It should be >= tWait but you know when I ran it, I couldn't tell the difference.