This demo is a countdown for 5 seconds, that is followed by a buzzer.
For every second, an LED lights up, and by the fifth second the buzzer goes off.

 

 

Code:


//define the outputs

const int LED2 = 2;
const int LED3 = 3;
const int LED4 = 4;
const int LED5 = 5;
const int LED6 = 6;
const int buzOutPin = 12;

//****************************<wbr />******************************<wbr />**********************

//set the starting point for alll LEDs to be turned off

void setup()

{
 digitalWrite(LED2, LOW);
 digitalWrite(LED3, LOW);
 digitalWrite(LED4, LOW);
 digitalWrite(LED5, LOW);
 digitalWrite(LED6, LOW);
}

//****************************<wbr />******************************<wbr />**********************

//create a loop that alternates the LEDs down a row, and at the end of the loop the buzzer goes off.

void loop()
{
 for(int i = 0; i < 4; i++) {
  digitalWrite(LED2, HIGH);
  delay(500);
  digitalWrite(LED2, LOW);
  delay(500);
  digitalWrite(LED3, HIGH);
  delay(500);
  digitalWrite(LED3, LOW);
  delay(500);
  digitalWrite(LED4, HIGH);
  delay(500);
  digitalWrite(LED4, LOW);
  delay(500);
  digitalWrite(LED5, HIGH);
  delay(500);
  digitalWrite(LED5, LOW);
  delay(500);
  digitalWrite(LED6, HIGH);
  delay(500);
  digitalWrite(LED6, LOW);
  tone(buzOutPin, HIGH);
  delay(1000);
  noTone(buzOutPin);
}
}
<pre>