Simon Ford
/
Flasher_example
Example showing how to avoid new with fixed pin names
Diff: main.cpp
- Revision:
- 0:16feaaa89263
- Child:
- 1:727520485a55
diff -r 000000000000 -r 16feaaa89263 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 21 22:11:41 2013 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +//test setting up an mbed pin as a class member initialized in the constructor +class flasher +{ +public: + DigitalOut* DO1; + DigitalOut* DO2; + flasher() { DO1 = new DigitalOut(LED1); DO2 = new DigitalOut(LED2);} //establish LED1 to flash + void flash(void) + { + *DO1 = 1; wait(0.25); *DO1 = 0; wait(0.25); + *DO2 = 0; wait(0.25); *DO2 = 1; wait(0.25); + } +}; + + +int main() { + flasher ff; + + while(1) { + ff.flash(); + wait(0.25); + } +} \ No newline at end of file