Simon Ford
/
Flasher_example
Example showing how to avoid new with fixed pin names
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 //test setting up an mbed pin as a class member initialized in the constructor 00003 class flasher 00004 { 00005 public: 00006 DigitalOut DO1; 00007 DigitalOut DO2; 00008 00009 flasher() : DO1(LED1), DO2(LED2) {} 00010 00011 void flash(void) 00012 { 00013 DO1 = 1; wait(0.25); DO1 = 0; wait(0.25); 00014 DO2 = 0; wait(0.25); DO2 = 1; wait(0.25); 00015 } 00016 }; 00017 00018 00019 int main() { 00020 flasher ff; 00021 00022 while(1) { 00023 ff.flash(); 00024 wait(0.25); 00025 } 00026 }
Generated on Tue Jul 12 2022 18:20:00 by 1.7.2