Thomas Morris / Mbed OS PROJ324_Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LED.cpp Source File

LED.cpp

00001 #include "LED.hpp"
00002 
00003 
00004 LED::LED(PinName pinName):pin(pinName)//Constuctor
00005 //Constuctor runs whenever a new instave of the class is created
00006 //The constructor has the same name as the class
00007 //The constructor does not have a return type
00008 //When called it needs to be given parameters Led redLed(D7);
00009 {
00010     
00011 }
00012 
00013 void LED::switchOn() //type void class is Led function is switchon
00014 {
00015     this->pin =1; //You access the attributes of the class by using the this command and then the name of the attribute
00016 }
00017 
00018 void LED::switchOff()//Turns off the LED
00019 {
00020     this->pin =0;
00021 }
00022 void LED::flash(float time)//Flashes the LED for the time passed in
00023 {
00024     this->pin = 1;
00025     Thread::wait(time);
00026     this->pin = 0;   
00027 }
00028 void LED::Toggle()//Toggles the current state of the LED
00029 {
00030     this->pin= !this->pin;
00031 }