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.
Name |
volatile |
Examples |
volatile int val;
void setup() {
attachInterrupt(EXTERNAL_INTERRUPT_2, myFunction, FALLING);
Serial.begin(9600);
}
void loop() {
val = 0;
while (val!=255)
continue;
Serial.println("Finally val is 255");
}
void myFunction() {
val = 255;
}
|
Description |
the volatile qualifier is applied to a variable when it is created. It tells the compiler the value of the variable may change at any time wihout any action being taken by the code around it. A variable has to be declared volatile whenever its value might change unexpectedly, like an interrupt service function (see the example above). |
Syntax |
volatile datatype variablename
|
Parameters |
datatype |
any data type: int, double, long, char, byte etc |
variablename |
a valid variable name |
|
Usage |
Application |
Updated on July 07, 2011 11:09:31pm PDT