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
Diff: Led.cpp
- Revision:
- 14:5d3bd2e4ac91
- Parent:
- 7:f3c3cb6cea26
- Child:
- 15:8c0d195355d2
diff -r 97f2c0033832 -r 5d3bd2e4ac91 Led.cpp
--- a/Led.cpp Thu Nov 12 13:38:11 2015 +0000
+++ b/Led.cpp Thu Nov 19 12:47:08 2015 +0000
@@ -1,28 +1,27 @@
-#include "Led.h" //includes the header with the class definition
-
+#include "led.h" //includes the header with the class definition
+#include <vector>
//constructor
-Led::Led(string s) //contructor implementation
+Led::Led(string name) //contructor implementation
{
- if(s== "red")
- pin= PD_14; //The pin for the red led
- if(s=="green")
- pin= PD_12;
- if(s== "blue")
- pin= PD_15;
- if(s=="orange")
- pin= PD_13;
-
-
- l = new DigitalOut(pin);
-
+ if(name == "red"){
+ this->pinName = PD_14; //The pin for the red led
+} else if(name == "green"){
+ this->pinName = PD_12;
+} else if(name == "orange"){
+ this->pinName = PD_13;
+} else if(name == "blue"){
+ this->pinName = PD_15;
}
-void Led::On() //function implementation
-{
- l->write(1); //set the value of the pin to l
+void Led::On() {
+ this->pin->write(1);
+ this->isOn = true;
}
-void Led::Off()
-{
- l->write(0); //set the value of the pin to 0
-}
\ No newline at end of file
+void Led::Off(){
+ this->pin->write(0);
+ this->isOn = false;
+}
+ bool Led::getIsOn(){
+ return this->isOn;
+}
