Plymouth ELEC351 Group T / Mbed OS ELEC351

Dependencies:   BME280 BMP280 TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LED.cpp Source File

LED.cpp

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