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.
Dependencies: mbed
main.cpp@0:09571003fc2e, 2018-09-20 (annotated)
- Committer:
- tmaly45
- Date:
- Thu Sep 20 18:49:31 2018 +0000
- Revision:
- 0:09571003fc2e
- Child:
- 1:0a1e7d18b69c
hi
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tmaly45 | 0:09571003fc2e | 1 | #include "mbed.h" |
| tmaly45 | 0:09571003fc2e | 2 | #include "time.h" |
| tmaly45 | 0:09571003fc2e | 3 | |
| tmaly45 | 0:09571003fc2e | 4 | DigitalOut myled[5] = {p25, p26, p27, p28, p29}; |
| tmaly45 | 0:09571003fc2e | 5 | |
| tmaly45 | 0:09571003fc2e | 6 | |
| tmaly45 | 0:09571003fc2e | 7 | |
| tmaly45 | 0:09571003fc2e | 8 | int main() { |
| tmaly45 | 0:09571003fc2e | 9 | |
| tmaly45 | 0:09571003fc2e | 10 | int i = 0; |
| tmaly45 | 0:09571003fc2e | 11 | |
| tmaly45 | 0:09571003fc2e | 12 | char enter_key; |
| tmaly45 | 0:09571003fc2e | 13 | |
| tmaly45 | 0:09571003fc2e | 14 | Timer t; |
| tmaly45 | 0:09571003fc2e | 15 | t.start(); |
| tmaly45 | 0:09571003fc2e | 16 | |
| tmaly45 | 0:09571003fc2e | 17 | printf("Ready?\n\r"); |
| tmaly45 | 0:09571003fc2e | 18 | scanf("%c", &enter_key); |
| tmaly45 | 0:09571003fc2e | 19 | srand(t.read_ms()); |
| tmaly45 | 0:09571003fc2e | 20 | |
| tmaly45 | 0:09571003fc2e | 21 | while(1) { |
| tmaly45 | 0:09571003fc2e | 22 | i = (rand()%4); |
| tmaly45 | 0:09571003fc2e | 23 | myled[i] = 1; |
| tmaly45 | 0:09571003fc2e | 24 | wait(1); |
| tmaly45 | 0:09571003fc2e | 25 | myled[i] = 0; |
| tmaly45 | 0:09571003fc2e | 26 | printf("%d\n\r", i); |
| tmaly45 | 0:09571003fc2e | 27 | } |
| tmaly45 | 0:09571003fc2e | 28 | |
| tmaly45 | 0:09571003fc2e | 29 | |
| tmaly45 | 0:09571003fc2e | 30 | } |