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
- Committer:
- Oschofield
- Date:
- 2015-11-27
- Revision:
- 20:85a44ddbdc41
- Parent:
- 19:6ad1702c5d90
File content as of revision 20:85a44ddbdc41:
#include "led.h" //include header file
//constructor
Led::Led(string s){ //Constructor implementation
if(s == "red")
pin = PD_14;
else if(s == "blue")
pin = PD_15;
else if(s == "green")
pin = PD_12;
else if(s == "orange")
pin = PD_13;
LedOut = new DigitalOut(pin);
}
void Led::On(){
LedOut -> write(1);
}
void Led::Off(){
LedOut -> write(0);
}
void Led::Flash(float Delay){
wait(Delay);
On();
wait(Delay);
Off();
}
bool Led::Status(){
return *LedOut;
}
bool Led::Toggle(){
if(this -> Status()){ // Checks if the current Pin out Status is on (true)
this->Off(); // turn LED off
return *LedOut; // return LED Status as Off
}
else{ // If Led is off
this->On(); // Turn Led on
return *LedOut; // return LED Status as On
}
}