Oscar Schofield / Mbed 2 deprecated Elec350_OBS

Dependencies:   mbed

led.cpp

Committer:
Oschofield
Date:
2015-11-27
Revision:
18:106b4cb3a647
Parent:
17:d46ebce20be0
Child:
19:6ad1702c5d90

File content as of revision 18:106b4cb3a647:

#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;
}

void Led::Toggle(){
    if(this -> Status()){
        this->Off();
        }else{
            this->On();
        }
}