![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
file
Fork of mbed_blinky by
main.cpp@3:ccd87cea3adc, 2015-11-25 (annotated)
- Committer:
- nehap
- Date:
- Wed Nov 25 09:35:52 2015 +0000
- Revision:
- 3:ccd87cea3adc
- Parent:
- 2:dc82c1187f3a
file;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tobiasmetzger | 0:cd939a0cfde7 | 1 | #include "mbed.h" |
nehap | 3:ccd87cea3adc | 2 | |
nehap | 3:ccd87cea3adc | 3 | class Flasher { |
nehap | 3:ccd87cea3adc | 4 | public: |
nehap | 3:ccd87cea3adc | 5 | Flasher(PinName pin) : _pin(pin) { // _pin(pin) means pass pin to the DigitalOut constructor |
nehap | 3:ccd87cea3adc | 6 | _pin = 0; // default the output to 0 |
nehap | 3:ccd87cea3adc | 7 | } |
nehap | 3:ccd87cea3adc | 8 | |
nehap | 3:ccd87cea3adc | 9 | void flash(int n) { |
nehap | 3:ccd87cea3adc | 10 | for(int i=0; i<n*2; i++) { |
nehap | 3:ccd87cea3adc | 11 | _pin = !_pin; |
nehap | 3:ccd87cea3adc | 12 | wait(0.2); |
nehap | 3:ccd87cea3adc | 13 | } |
nehap | 3:ccd87cea3adc | 14 | } |
nehap | 3:ccd87cea3adc | 15 | |
nehap | 3:ccd87cea3adc | 16 | private: |
nehap | 3:ccd87cea3adc | 17 | DigitalOut _pin; |
nehap | 3:ccd87cea3adc | 18 | }; |
nehap | 3:ccd87cea3adc | 19 | |
nehap | 3:ccd87cea3adc | 20 | Flasher led(LED2); |
nehap | 3:ccd87cea3adc | 21 | Flasher led1(LED3); |
nehap | 3:ccd87cea3adc | 22 | |
tobiasmetzger | 0:cd939a0cfde7 | 23 | int main() { |
nehap | 3:ccd87cea3adc | 24 | led.flash(5); |
nehap | 3:ccd87cea3adc | 25 | led.flash(2); |
nehap | 3:ccd87cea3adc | 26 | led1.flash(7); |
tobiasmetzger | 0:cd939a0cfde7 | 27 | } |