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

Dependencies:   mbed

Committer:
bjo3rn
Date:
Wed Sep 23 20:45:28 2015 +0000
Revision:
0:bc708d703171
initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bjo3rn 0:bc708d703171 1 #include "mbed.h"
bjo3rn 0:bc708d703171 2 #include "myWait.h"
bjo3rn 0:bc708d703171 3
bjo3rn 0:bc708d703171 4 // extern declares that the global variable greenLed is defined in a different source file
bjo3rn 0:bc708d703171 5 extern DigitalOut greenLed;
bjo3rn 0:bc708d703171 6
bjo3rn 0:bc708d703171 7 // definition of our custom wait function
bjo3rn 0:bc708d703171 8 void myWait(float t) {
bjo3rn 0:bc708d703171 9 greenLed=0; //turn on
bjo3rn 0:bc708d703171 10 wait(t); //wait
bjo3rn 0:bc708d703171 11 greenLed=1; //turn off
bjo3rn 0:bc708d703171 12 }