Thomas Morris / Mbed 2 deprecated ELEC_350_Coursework_v1

Dependencies:   TextLCD mbed-rtos mbed

Fork of ELEC_350_Coursework by Chris Hills

Committer:
thomasmorris
Date:
Sat Nov 25 15:39:56 2017 +0000
Revision:
0:8f564feffdd8
Version_1.0; Working LCD

Who changed what in which revision?

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