Framework (A-Z)

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.



void setup()

void loop()
  // x is initialized only once across the calls of loop()
  static int x = 0;   
  Serial.println(x);  // outputs the value of x
  x = x + 1;  
Description the static qualifier is used to create a static variable, its lifetime extends across the entire run of the program. As shown in the example the static variable x is only visible inside loop(). Try to remove the static qualifier in the axample above and see the difference when printing the output.
static datatype variablename
datatype any data type: int, double, long, char, byte, etc
variablename a valid variable name
Usage Application
Updated on July 07, 2011 11:09:02pm PDT

Creative Commons License