Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:3a4784da8745, 2016-10-13 (annotated)
- Committer:
- yyue
- Date:
- Thu Oct 13 09:19:45 2016 +0000
- Revision:
- 0:3a4784da8745
Created my library.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yyue | 0:3a4784da8745 | 1 | #include "mbed.h" |
| yyue | 0:3a4784da8745 | 2 | #include "Led.h" |
| yyue | 0:3a4784da8745 | 3 | #include "Button.h" |
| yyue | 0:3a4784da8745 | 4 | Led myled(PD_15); |
| yyue | 0:3a4784da8745 | 5 | Led myled1(PD_12); |
| yyue | 0:3a4784da8745 | 6 | Led myled2(PD_13); |
| yyue | 0:3a4784da8745 | 7 | Led myled3(PD_14); |
| yyue | 0:3a4784da8745 | 8 | Button button(PA_0); |
| yyue | 0:3a4784da8745 | 9 | int main() |
| yyue | 0:3a4784da8745 | 10 | { |
| yyue | 0:3a4784da8745 | 11 | float delay = 0.01f; |
| yyue | 0:3a4784da8745 | 12 | while(1) { |
| yyue | 0:3a4784da8745 | 13 | while(button.isPressed()) { |
| yyue | 0:3a4784da8745 | 14 | myled.switchOff(); |
| yyue | 0:3a4784da8745 | 15 | myled1.switchOff(); |
| yyue | 0:3a4784da8745 | 16 | myled2.switchOff(); |
| yyue | 0:3a4784da8745 | 17 | myled3.switchOff(); |
| yyue | 0:3a4784da8745 | 18 | int led = rand() % 4; |
| yyue | 0:3a4784da8745 | 19 | if (led == 0) { |
| yyue | 0:3a4784da8745 | 20 | myled.flash(0.1); |
| yyue | 0:3a4784da8745 | 21 | } else if (led == 1) { |
| yyue | 0:3a4784da8745 | 22 | myled1.flash(0.1); |
| yyue | 0:3a4784da8745 | 23 | } else if (led==2) { |
| yyue | 0:3a4784da8745 | 24 | myled2.flash(0.1); |
| yyue | 0:3a4784da8745 | 25 | } else { |
| yyue | 0:3a4784da8745 | 26 | myled3.flash(0.1); |
| yyue | 0:3a4784da8745 | 27 | } |
| yyue | 0:3a4784da8745 | 28 | wait(delay); |
| yyue | 0:3a4784da8745 | 29 | } |
| yyue | 0:3a4784da8745 | 30 | } |
| yyue | 0:3a4784da8745 | 31 | } |