Diana Saveh
/
led
Library A: LED library to controll the led on the Happy Gecko.
led.cpp@1:55b5e6d28fb3, 2018-02-12 (annotated)
- Committer:
- diana_s
- Date:
- Mon Feb 12 21:40:22 2018 +0000
- Revision:
- 1:55b5e6d28fb3
- Parent:
- 0:3cabc617d433
updated doc;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
diana_s | 0:3cabc617d433 | 1 | #include "LED.h" |
diana_s | 0:3cabc617d433 | 2 | #include "mbed.h" |
diana_s | 0:3cabc617d433 | 3 | |
diana_s | 0:3cabc617d433 | 4 | LED::LED(PinName pin): LEDpin(pin) { |
diana_s | 0:3cabc617d433 | 5 | LEDpin=0; |
diana_s | 0:3cabc617d433 | 6 | } |
diana_s | 0:3cabc617d433 | 7 | |
diana_s | 0:3cabc617d433 | 8 | void LED::ledOn(){ |
diana_s | 0:3cabc617d433 | 9 | LEDpin = 1; |
diana_s | 0:3cabc617d433 | 10 | } |
diana_s | 0:3cabc617d433 | 11 | |
diana_s | 0:3cabc617d433 | 12 | void LED::ledOff(){ |
diana_s | 0:3cabc617d433 | 13 | LEDpin = 0; |
diana_s | 0:3cabc617d433 | 14 | } |
diana_s | 0:3cabc617d433 | 15 | |
diana_s | 0:3cabc617d433 | 16 | void LED::toggle(){ |
diana_s | 0:3cabc617d433 | 17 | LEDpin = !LEDpin; |
diana_s | 0:3cabc617d433 | 18 | } |
diana_s | 0:3cabc617d433 | 19 | |
diana_s | 1:55b5e6d28fb3 | 20 | |
diana_s | 0:3cabc617d433 | 21 | void LED::blink(float duration) { |
diana_s | 0:3cabc617d433 | 22 | this->toggle(); |
diana_s | 0:3cabc617d433 | 23 | wait(duration); |
diana_s | 0:3cabc617d433 | 24 | this->toggle(); |
diana_s | 0:3cabc617d433 | 25 | } |