Simple library for LED blinking.
Dependents: roam_v2 finalV1 finalV1 finalv2 ... more
Blinker.h@2:190915d53c0b, 2015-11-15 (annotated)
- Committer:
- tbjazic
- Date:
- Sun Nov 15 09:12:51 2015 +0000
- Revision:
- 2:190915d53c0b
- Parent:
- 1:ea5bb72717cc
- Child:
- 3:286a364f952f
Documentation updated.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:c9a302c4bed9 | 1 | #ifndef MBED_BLINKER_H_TB |
tbjazic | 0:c9a302c4bed9 | 2 | #define MBED_BLINKER_H_TB |
tbjazic | 0:c9a302c4bed9 | 3 | |
tbjazic | 0:c9a302c4bed9 | 4 | #include "mbed.h" |
tbjazic | 0:c9a302c4bed9 | 5 | |
tbjazic | 2:190915d53c0b | 6 | /** Simple class for learning development of libraries. The main task |
tbjazic | 2:190915d53c0b | 7 | * is to blink (flash) a LED connected to a specified pin N times. |
tbjazic | 2:190915d53c0b | 8 | * Each blink should last 0.5 seconds by default, or some other time |
tbjazic | 2:190915d53c0b | 9 | * that user can set. |
tbjazic | 1:ea5bb72717cc | 10 | * |
tbjazic | 1:ea5bb72717cc | 11 | * Author: TVZ Mechatronics Team |
tbjazic | 1:ea5bb72717cc | 12 | * |
tbjazic | 1:ea5bb72717cc | 13 | * Example of use: |
tbjazic | 1:ea5bb72717cc | 14 | * @code |
tbjazic | 1:ea5bb72717cc | 15 | * #include "mbed.h" |
tbjazic | 1:ea5bb72717cc | 16 | * #include "Blinker.h" |
tbjazic | 1:ea5bb72717cc | 17 | * |
tbjazic | 1:ea5bb72717cc | 18 | * int main() { |
tbjazic | 2:190915d53c0b | 19 | * Blinker myBlinker(LED3); |
tbjazic | 2:190915d53c0b | 20 | * myBlinker.blink(10); |
tbjazic | 1:ea5bb72717cc | 21 | * wait(2); |
tbjazic | 2:190915d53c0b | 22 | * myBlinker.blink(5, 1); |
tbjazic | 1:ea5bb72717cc | 23 | * } |
tbjazic | 1:ea5bb72717cc | 24 | * @endcode |
tbjazic | 1:ea5bb72717cc | 25 | */ |
tbjazic | 0:c9a302c4bed9 | 26 | class Blinker { |
tbjazic | 0:c9a302c4bed9 | 27 | private: |
tbjazic | 0:c9a302c4bed9 | 28 | DigitalOut myled; |
tbjazic | 0:c9a302c4bed9 | 29 | public: |
tbjazic | 2:190915d53c0b | 30 | /** Constructor receives a pin name that LED is connected to. */ |
tbjazic | 0:c9a302c4bed9 | 31 | Blinker(PinName pin); |
tbjazic | 2:190915d53c0b | 32 | /** Function recevies number of blinks (flashes) and a time of duration of each blink. */ |
tbjazic | 2:190915d53c0b | 33 | void blink(int n, float t = 0.5); |
tbjazic | 0:c9a302c4bed9 | 34 | }; |
tbjazic | 0:c9a302c4bed9 | 35 | |
tbjazic | 0:c9a302c4bed9 | 36 | #endif |