program to blink two leds along with value of N
Fork of blink_LED by
blink.cpp@1:7a062c1b79dd, 2016-11-11 (annotated)
- Committer:
- 2bv14ei014
- Date:
- Fri Nov 11 06:41:04 2016 +0000
- Revision:
- 1:7a062c1b79dd
- Parent:
- 0:d1d2410ad028
BLINK LEDS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
2bv14ei014 | 0:d1d2410ad028 | 1 | #include "Blinker.h" |
2bv14ei014 | 0:d1d2410ad028 | 2 | #include "mbed.h" |
2bv14ei014 | 0:d1d2410ad028 | 3 | |
2bv14ei014 | 0:d1d2410ad028 | 4 | Blinker::Blinker(PinName pin) : LED1(pin) |
2bv14ei014 | 0:d1d2410ad028 | 5 | { |
2bv14ei014 | 0:d1d2410ad028 | 6 | LED1 = 0; |
2bv14ei014 | 0:d1d2410ad028 | 7 | } |
2bv14ei014 | 0:d1d2410ad028 | 8 | LED2(pin) |
2bv14ei014 | 0:d1d2410ad028 | 9 | { |
2bv14ei014 | 0:d1d2410ad028 | 10 | LED2 = 0; |
2bv14ei014 | 0:d1d2410ad028 | 11 | } |
2bv14ei014 | 0:d1d2410ad028 | 12 | void Blinker::Blink(int n) { |
2bv14ei014 | 0:d1d2410ad028 | 13 | for(int i=0; i<n*2; i++) { |
2bv14ei014 | 0:d1d2410ad028 | 14 | LED1=1; |
2bv14ei014 | 0:d1d2410ad028 | 15 | wait(0.2); |
2bv14ei014 | 0:d1d2410ad028 | 16 | LED1=0; |
2bv14ei014 | 0:d1d2410ad028 | 17 | wait(0.2); |
2bv14ei014 | 0:d1d2410ad028 | 18 | LED2=1; |
2bv14ei014 | 0:d1d2410ad028 | 19 | wait(0.2); |
2bv14ei014 | 0:d1d2410ad028 | 20 | LED2=0; |
2bv14ei014 | 0:d1d2410ad028 | 21 | wait(0.2); |
2bv14ei014 | 0:d1d2410ad028 | 22 | |
2bv14ei014 | 0:d1d2410ad028 | 23 | |
2bv14ei014 | 0:d1d2410ad028 | 24 | } |
2bv14ei014 | 0:d1d2410ad028 | 25 | } |