JIAWEI ZHANG / Mbed 2 deprecated ele350ku

Dependencies:   mbed

Dependents:   Exercise8_1-2-3

Fork of ele350 by JIAWEI ZHANG

Committer:
GGHHHH
Date:
Thu Nov 19 13:28:08 2015 +0000
Revision:
17:e92adffd15c7
Parent:
16:085b9b2a9343
0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GGHHHH 16:085b9b2a9343 1 #include "Led.h" //includes the header with the class definition
GGHHHH 14:5d3bd2e4ac91 2 #include <vector>
GGHHHH 0:b43794060b94 3 //constructor
GGHHHH 14:5d3bd2e4ac91 4 Led::Led(string name) //contructor implementation
GGHHHH 0:b43794060b94 5 {
GGHHHH 16:085b9b2a9343 6 if(name == "red") {
GGHHHH 16:085b9b2a9343 7 this->pinName = PD_14; //The pin for the red led
GGHHHH 16:085b9b2a9343 8 } else if(name == "green") {
GGHHHH 16:085b9b2a9343 9 this->pinName = PD_12;
GGHHHH 16:085b9b2a9343 10 } else if(name == "orange") {
GGHHHH 16:085b9b2a9343 11 this->pinName = PD_13;
GGHHHH 16:085b9b2a9343 12 } else if(name == "blue") {
GGHHHH 16:085b9b2a9343 13 this->pinName = PD_15;
GGHHHH 16:085b9b2a9343 14 }
GGHHHH 17:e92adffd15c7 15
GGHHHH 17:e92adffd15c7 16 pin = new DigitalOut (pinName);
GGHHHH 16:085b9b2a9343 17 }
GGHHHH 16:085b9b2a9343 18 void Led::On()
GGHHHH 16:085b9b2a9343 19 {
GGHHHH 16:085b9b2a9343 20 this->pin->write(1);
GGHHHH 16:085b9b2a9343 21 this->isSwitchedOn = true;
GGHHHH 0:b43794060b94 22 }
GGHHHH 0:b43794060b94 23
GGHHHH 16:085b9b2a9343 24 void Led::Off()
GGHHHH 16:085b9b2a9343 25 {
GGHHHH 16:085b9b2a9343 26 this->pin->write(0);
GGHHHH 16:085b9b2a9343 27 this->isSwitchedOn = false;
GGHHHH 0:b43794060b94 28 }
GGHHHH 16:085b9b2a9343 29 bool Led::getIsSwitchenOn()
GGHHHH 16:085b9b2a9343 30 {
GGHHHH 16:085b9b2a9343 31 return this->isSwitchedOn;
GGHHHH 14:5d3bd2e4ac91 32 }