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 ele350 by
Led.cpp@16:085b9b2a9343, 2015-11-19 (annotated)
- Committer:
- GGHHHH
- Date:
- Thu Nov 19 13:11:55 2015 +0000
- Revision:
- 16:085b9b2a9343
- Parent:
- 15:8c0d195355d2
- Child:
- 17:e92adffd15c7
0
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| GGHHHH | 16:085b9b2a9343 | 1 | #include "Led.h" //includes the header with the class definition |
| GGHHHH | 14:5d3bd2e4ac91 | 2 | #include <vector> |
| GGHHHH | 0:b43794060b94 | 3 | //constructor |
| GGHHHH | 14:5d3bd2e4ac91 | 4 | Led::Led(string name) //contructor implementation |
| GGHHHH | 0:b43794060b94 | 5 | { |
| GGHHHH | 16:085b9b2a9343 | 6 | if(name == "red") { |
| GGHHHH | 16:085b9b2a9343 | 7 | this->pinName = PD_14; //The pin for the red led |
| GGHHHH | 16:085b9b2a9343 | 8 | } else if(name == "green") { |
| GGHHHH | 16:085b9b2a9343 | 9 | this->pinName = PD_12; |
| GGHHHH | 16:085b9b2a9343 | 10 | } else if(name == "orange") { |
| GGHHHH | 16:085b9b2a9343 | 11 | this->pinName = PD_13; |
| GGHHHH | 16:085b9b2a9343 | 12 | } else if(name == "blue") { |
| GGHHHH | 16:085b9b2a9343 | 13 | this->pinName = PD_15; |
| GGHHHH | 16:085b9b2a9343 | 14 | } |
| GGHHHH | 16:085b9b2a9343 | 15 | } |
| GGHHHH | 16:085b9b2a9343 | 16 | void Led::On() |
| GGHHHH | 16:085b9b2a9343 | 17 | { |
| GGHHHH | 16:085b9b2a9343 | 18 | this->pin->write(1); |
| GGHHHH | 16:085b9b2a9343 | 19 | this->isSwitchedOn = true; |
| GGHHHH | 0:b43794060b94 | 20 | } |
| GGHHHH | 0:b43794060b94 | 21 | |
| GGHHHH | 16:085b9b2a9343 | 22 | void Led::Off() |
| GGHHHH | 16:085b9b2a9343 | 23 | { |
| GGHHHH | 16:085b9b2a9343 | 24 | this->pin->write(0); |
| GGHHHH | 16:085b9b2a9343 | 25 | this->isSwitchedOn = false; |
| GGHHHH | 0:b43794060b94 | 26 | } |
| GGHHHH | 16:085b9b2a9343 | 27 | bool Led::getIsSwitchenOn() |
| GGHHHH | 16:085b9b2a9343 | 28 | { |
| GGHHHH | 16:085b9b2a9343 | 29 | return this->isSwitchedOn; |
| GGHHHH | 14:5d3bd2e4ac91 | 30 | } |
