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.
led.cpp@1:16b0f2898739, 2015-10-15 (annotated)
- Committer:
- Oschofield
- Date:
- Thu Oct 15 11:20:49 2015 +0000
- Revision:
- 1:16b0f2898739
- Child:
- 17:d46ebce20be0
Added button classes and methods;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Oschofield | 1:16b0f2898739 | 1 | #include "led.h" //include header file |
Oschofield | 1:16b0f2898739 | 2 | |
Oschofield | 1:16b0f2898739 | 3 | //constructor |
Oschofield | 1:16b0f2898739 | 4 | |
Oschofield | 1:16b0f2898739 | 5 | Led::Led(string s){ //Constructor implementation |
Oschofield | 1:16b0f2898739 | 6 | if(s == "red") |
Oschofield | 1:16b0f2898739 | 7 | pin = PD_14; |
Oschofield | 1:16b0f2898739 | 8 | |
Oschofield | 1:16b0f2898739 | 9 | else if(s == "blue") |
Oschofield | 1:16b0f2898739 | 10 | pin = PD_15; |
Oschofield | 1:16b0f2898739 | 11 | |
Oschofield | 1:16b0f2898739 | 12 | else if(s == "green") |
Oschofield | 1:16b0f2898739 | 13 | pin = PD_12; |
Oschofield | 1:16b0f2898739 | 14 | |
Oschofield | 1:16b0f2898739 | 15 | else if(s == "orange") |
Oschofield | 1:16b0f2898739 | 16 | pin = PD_13; |
Oschofield | 1:16b0f2898739 | 17 | LedOut = new DigitalOut(pin); |
Oschofield | 1:16b0f2898739 | 18 | } |
Oschofield | 1:16b0f2898739 | 19 | |
Oschofield | 1:16b0f2898739 | 20 | void Led::On(){ |
Oschofield | 1:16b0f2898739 | 21 | LedOut -> write(1); |
Oschofield | 1:16b0f2898739 | 22 | } |
Oschofield | 1:16b0f2898739 | 23 | |
Oschofield | 1:16b0f2898739 | 24 | void Led::Off(){ |
Oschofield | 1:16b0f2898739 | 25 | LedOut -> write(0); |
Oschofield | 1:16b0f2898739 | 26 | } |
Oschofield | 1:16b0f2898739 | 27 | |
Oschofield | 1:16b0f2898739 | 28 | void Led::Flash(float Delay){ |
Oschofield | 1:16b0f2898739 | 29 | wait(Delay); |
Oschofield | 1:16b0f2898739 | 30 | On(); |
Oschofield | 1:16b0f2898739 | 31 | wait(Delay); |
Oschofield | 1:16b0f2898739 | 32 | Off(); |
Oschofield | 1:16b0f2898739 | 33 | } |