Example of an "extern" declaration to reuse a global variable defined in one file in another file.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers myWait.cpp Source File

myWait.cpp

00001 #include "mbed.h"
00002 #include "myWait.h"
00003 
00004 // extern declares that the global variable greenLed is defined in a different source file
00005 extern DigitalOut greenLed;
00006 
00007 // definition of our custom wait function
00008 void myWait(float t) {
00009     greenLed=0; //turn on
00010     wait(t); //wait
00011     greenLed=1; //turn off
00012 }