Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HelloWorld by
main.cpp@3:966b57ac5efc, 2015-11-25 (annotated)
- Committer:
- ashapawar
- Date:
- Wed Nov 25 12:33:02 2015 +0000
- Revision:
- 3:966b57ac5efc
- Parent:
- 2:d42b0e3fe08a
own library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:fb6bbc10ffa0 | 1 | #include "mbed.h" |
ashapawar | 3:966b57ac5efc | 2 | class Flasher { |
ashapawar | 3:966b57ac5efc | 3 | public: |
ashapawar | 3:966b57ac5efc | 4 | Flasher(PinName pin) : _pin(pin) { // _pin(pin) means pass pin to the DigitalOut constructor |
ashapawar | 3:966b57ac5efc | 5 | _pin = 0; // default the output to 0 |
ashapawar | 3:966b57ac5efc | 6 | } |
ashapawar | 3:966b57ac5efc | 7 | |
ashapawar | 3:966b57ac5efc | 8 | void flash(int n) { |
ashapawar | 3:966b57ac5efc | 9 | for(int i=0; i<n*2; i++) { |
ashapawar | 3:966b57ac5efc | 10 | _pin = !_pin; |
ashapawar | 3:966b57ac5efc | 11 | wait(0.2); |
ashapawar | 3:966b57ac5efc | 12 | } |
ashapawar | 3:966b57ac5efc | 13 | } |
ashapawar | 3:966b57ac5efc | 14 | private: |
ashapawar | 3:966b57ac5efc | 15 | DigitalOut _pin; |
ashapawar | 3:966b57ac5efc | 16 | }; |
ashapawar | 2:d42b0e3fe08a | 17 | |
ashapawar | 2:d42b0e3fe08a | 18 | Flasher led(LED2); |
ashapawar | 3:966b57ac5efc | 19 | Flasher out(LED3); |
ashapawar | 2:d42b0e3fe08a | 20 | |
simon | 0:fb6bbc10ffa0 | 21 | int main() { |
ashapawar | 2:d42b0e3fe08a | 22 | led.flash(5); |
ashapawar | 2:d42b0e3fe08a | 23 | led.flash(2); |
ashapawar | 3:966b57ac5efc | 24 | out.flash(10); |
simon | 0:fb6bbc10ffa0 | 25 | } |
ashapawar | 2:d42b0e3fe08a | 26 |