
elec350
Fork of elec350 by
Diff: led.cpp
- Revision:
- 15:c1362c12a896
- Parent:
- 7:aa63d1e53be6
--- a/led.cpp Thu Oct 22 08:40:54 2015 +0000 +++ b/led.cpp Tue Nov 10 20:12:21 2015 +0000 @@ -1,6 +1,7 @@ #include "led.h" #include <vector> +// Led class contructor. Led::Led(string name) { if (name == "red") { this->pinName = PD_14; @@ -13,12 +14,24 @@ } this->pin = new DigitalOut(this->pinName); + this->isOn = false; } +// Method to switch the LED on. void Led::On() { this->pin->write(1); + this->isOn = true; } +// Method to switch the LED off. void Led::Off() { this->pin->write(0); -} \ No newline at end of file + this->isOn = false; +} + +// Method to get the current state of the LED. +// (true=on, false=off). +bool Led::getIsOn() { + return this->isOn; +} +