Statements and comments

This example is for Wiring version 0024+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

Setup and Loop.

The loop() function creates a structure in which to write programs that change with time.


// The statements in the setup() function 
// execute once when the program begins
void setup() 
{
  pinMode(48, OUTPUT);  // Set the pin 48 (onboard LED) as OUTPUT
  digitalWrite(48, HIGH);     // Set the pin 48 as HIGH (turn ON the onboard LED)
}

int y = 100;

// The statements in loop() are executed until the 
// board is stopped. Each statement is executed in 
// sequence and after the last line is read, the first 
// line is executed again.
void loop() 
{ 
  if (y > 0) {  // Blink the LED while y > 0
    digitalWrite(48, LOW);   
    delay(100);
    digitalWrite(48, HIGH); 
    delay(100);
  }
  y = y - 1;  
}