use the Ticker class to make a breathing led
Dependencies: mbed
Fork of Ticker_HelloWorld by
main.cpp@2:7a5c6bccf83c, 2014-10-21 (annotated)
- Committer:
- shiyilei
- Date:
- Tue Oct 21 15:27:35 2014 +0000
- Revision:
- 2:7a5c6bccf83c
- Parent:
- 0:5014bf742e9b
use the Ticker class to make a breathing led
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shiyilei | 2:7a5c6bccf83c | 1 | /**************************************************************** |
shiyilei | 2:7a5c6bccf83c | 2 | *file name : breathing led |
shiyilei | 2:7a5c6bccf83c | 3 | *Creator:JacobShi |
shiyilei | 2:7a5c6bccf83c | 4 | *Time:2014/10/20 |
shiyilei | 2:7a5c6bccf83c | 5 | * Description :use the Ticker class to make a breathing led |
shiyilei | 2:7a5c6bccf83c | 6 | *************************************************************/ |
mbed_official | 0:5014bf742e9b | 7 | #include "mbed.h" |
shiyilei | 2:7a5c6bccf83c | 8 | Ticker basetime; |
shiyilei | 2:7a5c6bccf83c | 9 | |
shiyilei | 2:7a5c6bccf83c | 10 | DigitalOut myled(LED1); |
shiyilei | 2:7a5c6bccf83c | 11 | void led_change(void) |
shiyilei | 2:7a5c6bccf83c | 12 | { |
shiyilei | 2:7a5c6bccf83c | 13 | myled=!myled; |
mbed_official | 0:5014bf742e9b | 14 | } |
shiyilei | 2:7a5c6bccf83c | 15 | |
shiyilei | 2:7a5c6bccf83c | 16 | |
shiyilei | 2:7a5c6bccf83c | 17 | int main(void) |
shiyilei | 2:7a5c6bccf83c | 18 | { |
shiyilei | 2:7a5c6bccf83c | 19 | basetime.attach(&led_change,1); |
shiyilei | 2:7a5c6bccf83c | 20 | while(1) |
shiyilei | 2:7a5c6bccf83c | 21 | { |
shiyilei | 2:7a5c6bccf83c | 22 | |
mbed_official | 0:5014bf742e9b | 23 | } |
mbed_official | 0:5014bf742e9b | 24 | } |