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.
Dependencies: mbed
Blinker.h@0:dff21578688b, 2016-08-13 (annotated)
- Committer:
- mattshuman
- Date:
- Sat Aug 13 01:25:25 2016 +0000
- Revision:
- 0:dff21578688b
This provides a template about how to use a .h file to organize programs into logical classes.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mattshuman | 0:dff21578688b | 1 | #include "mbed.h" |
| mattshuman | 0:dff21578688b | 2 | // this class file is a template on using .h files. |
| mattshuman | 0:dff21578688b | 3 | class Blinker |
| mattshuman | 0:dff21578688b | 4 | { |
| mattshuman | 0:dff21578688b | 5 | public: |
| mattshuman | 0:dff21578688b | 6 | Blinker(void) { |
| mattshuman | 0:dff21578688b | 7 | // _pin(pin) means pass pin to the Blinker Constructor |
| mattshuman | 0:dff21578688b | 8 | }; |
| mattshuman | 0:dff21578688b | 9 | // class method to blink and LED based on the PwmOut class |
| mattshuman | 0:dff21578688b | 10 | void blink(PwmOut outputLED, float frequency, float brightness) { |
| mattshuman | 0:dff21578688b | 11 | outputLED.period(.001f); |
| mattshuman | 0:dff21578688b | 12 | outputLED = 1- brightness; |
| mattshuman | 0:dff21578688b | 13 | float duration = (1.0/frequency)/2; |
| mattshuman | 0:dff21578688b | 14 | wait(duration); |
| mattshuman | 0:dff21578688b | 15 | outputLED = 1.0; |
| mattshuman | 0:dff21578688b | 16 | wait(duration); |
| mattshuman | 0:dff21578688b | 17 | }; |
| mattshuman | 0:dff21578688b | 18 | |
| mattshuman | 0:dff21578688b | 19 | private: |
| mattshuman | 0:dff21578688b | 20 | |
| mattshuman | 0:dff21578688b | 21 | }; |