Task 1,7,8 Working

Dependencies:   BME280 BMP280 ELEC350-Coursework-2017 TextLCD

Fork of ELEC350-CWTEMPLATE-2017 by University of Plymouth - Stages 1, 2 and 3

Committer:
thomasmorris
Date:
Sun Dec 10 17:30:00 2017 +0000
Revision:
5:2594b953f111
Task 1,5,8 Working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 5:2594b953f111 1 #include "mbed.h"
thomasmorris 5:2594b953f111 2 #include "LED.hpp"
thomasmorris 5:2594b953f111 3
thomasmorris 5:2594b953f111 4
thomasmorris 5:2594b953f111 5 LED::LED(PinName pinName):pin(pinName)//Constuctor
thomasmorris 5:2594b953f111 6 //Constuctor runs whenever a new instave of the class is created
thomasmorris 5:2594b953f111 7 //The constructor has the same name as the class
thomasmorris 5:2594b953f111 8 //The constructor does not have a return type
thomasmorris 5:2594b953f111 9 //When called it needs to be given parameters Led redLed(D7);
thomasmorris 5:2594b953f111 10 {
thomasmorris 5:2594b953f111 11
thomasmorris 5:2594b953f111 12 }
thomasmorris 5:2594b953f111 13
thomasmorris 5:2594b953f111 14 void LED::switchOn() //type void class is Led function is switchon
thomasmorris 5:2594b953f111 15 {
thomasmorris 5:2594b953f111 16 this->pin =1; //You access the attributes of the class by using the this command and then the name of the attribute
thomasmorris 5:2594b953f111 17 }
thomasmorris 5:2594b953f111 18
thomasmorris 5:2594b953f111 19 void LED::switchOff()
thomasmorris 5:2594b953f111 20 {
thomasmorris 5:2594b953f111 21 this->pin =0;
thomasmorris 5:2594b953f111 22 }
thomasmorris 5:2594b953f111 23 void LED::flash(float time)
thomasmorris 5:2594b953f111 24 {
thomasmorris 5:2594b953f111 25 this->pin = 1;
thomasmorris 5:2594b953f111 26 wait(time);
thomasmorris 5:2594b953f111 27 this->pin = 0;
thomasmorris 5:2594b953f111 28 }
thomasmorris 5:2594b953f111 29 void LED::Toggle()
thomasmorris 5:2594b953f111 30 {
thomasmorris 5:2594b953f111 31 this->pin= !this->pin;
thomasmorris 5:2594b953f111 32 }