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:06:59 2015 +0000
Revision:
15:8c0d195355d2
Parent:
14:5d3bd2e4ac91
Child:
16:085b9b2a9343
0; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GGHHHH 14:5d3bd2e4ac91 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 14:5d3bd2e4ac91 6 if(name == "red"){
GGHHHH 14:5d3bd2e4ac91 7 this->pinName = PD_14; //The pin for the red led
GGHHHH 14:5d3bd2e4ac91 8 } else if(name == "green"){
GGHHHH 14:5d3bd2e4ac91 9 this->pinName = PD_12;
GGHHHH 14:5d3bd2e4ac91 10 } else if(name == "orange"){
GGHHHH 14:5d3bd2e4ac91 11 this->pinName = PD_13;
GGHHHH 14:5d3bd2e4ac91 12 } else if(name == "blue"){
GGHHHH 14:5d3bd2e4ac91 13 this->pinName = PD_15;
GGHHHH 0:b43794060b94 14 }
GGHHHH 0:b43794060b94 15
GGHHHH 14:5d3bd2e4ac91 16 void Led::On() {
GGHHHH 14:5d3bd2e4ac91 17 this->pin->write(1);
GGHHHH 15:8c0d195355d2 18 this->isSwitchedOn = true;
GGHHHH 0:b43794060b94 19 }
GGHHHH 0:b43794060b94 20
GGHHHH 14:5d3bd2e4ac91 21 void Led::Off(){
GGHHHH 14:5d3bd2e4ac91 22 this->pin->write(0);
GGHHHH 15:8c0d195355d2 23 this->isSwitchedOn = false;
GGHHHH 14:5d3bd2e4ac91 24 }
GGHHHH 15:8c0d195355d2 25 bool Led::getIsSwitchenOn(){
GGHHHH 15:8c0d195355d2 26 return this->isSwitchedOn;
GGHHHH 14:5d3bd2e4ac91 27 }