Basic Led Library

Committer:
WakoTakeru
Date:
Sat Feb 18 04:11:45 2017 +0000
Revision:
0:ccc1d1ad706f
Basic Led Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WakoTakeru 0:ccc1d1ad706f 1 #include "mbed.h"
WakoTakeru 0:ccc1d1ad706f 2 #include "LED.h"
WakoTakeru 0:ccc1d1ad706f 3
WakoTakeru 0:ccc1d1ad706f 4 Led::Led(PinName pin):_pin(pin){
WakoTakeru 0:ccc1d1ad706f 5 _pin = 0;
WakoTakeru 0:ccc1d1ad706f 6 state = false;
WakoTakeru 0:ccc1d1ad706f 7 }
WakoTakeru 0:ccc1d1ad706f 8
WakoTakeru 0:ccc1d1ad706f 9 void Led::On(){
WakoTakeru 0:ccc1d1ad706f 10 _pin = 1;
WakoTakeru 0:ccc1d1ad706f 11 state = true;
WakoTakeru 0:ccc1d1ad706f 12 }
WakoTakeru 0:ccc1d1ad706f 13 void Led::Off(){
WakoTakeru 0:ccc1d1ad706f 14 _pin = 0;
WakoTakeru 0:ccc1d1ad706f 15 state = false;
WakoTakeru 0:ccc1d1ad706f 16 }
WakoTakeru 0:ccc1d1ad706f 17
WakoTakeru 0:ccc1d1ad706f 18 void Led::Toggle(){
WakoTakeru 0:ccc1d1ad706f 19 if(state){
WakoTakeru 0:ccc1d1ad706f 20 Led::Off();
WakoTakeru 0:ccc1d1ad706f 21 }else{
WakoTakeru 0:ccc1d1ad706f 22 Led::On();
WakoTakeru 0:ccc1d1ad706f 23 }
WakoTakeru 0:ccc1d1ad706f 24 }