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:aba03316ce9e, 2010-10-12 (annotated)
- Committer:
- nothing
- Date:
- Tue Oct 12 14:37:48 2010 +0000
- Revision:
- 0:aba03316ce9e
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nothing | 0:aba03316ce9e | 1 | #include "mbed.h" |
| nothing | 0:aba03316ce9e | 2 | |
| nothing | 0:aba03316ce9e | 3 | DigitalOut myled1(LED1); |
| nothing | 0:aba03316ce9e | 4 | DigitalOut myled2(LED2); |
| nothing | 0:aba03316ce9e | 5 | DigitalOut myled3(LED3); |
| nothing | 0:aba03316ce9e | 6 | DigitalOut myled4(LED4); |
| nothing | 0:aba03316ce9e | 7 | |
| nothing | 0:aba03316ce9e | 8 | int counter; |
| nothing | 0:aba03316ce9e | 9 | |
| nothing | 0:aba03316ce9e | 10 | void countup() { |
| nothing | 0:aba03316ce9e | 11 | |
| nothing | 0:aba03316ce9e | 12 | for (counter = 1; counter < 9; counter = counter << 1) { |
| nothing | 0:aba03316ce9e | 13 | myled1 = counter & 1; |
| nothing | 0:aba03316ce9e | 14 | myled2 = (counter >> 1) & 1; |
| nothing | 0:aba03316ce9e | 15 | myled3 = (counter >> 2) & 1; |
| nothing | 0:aba03316ce9e | 16 | myled4 = (counter >> 3) & 1; |
| nothing | 0:aba03316ce9e | 17 | wait(0.1); |
| nothing | 0:aba03316ce9e | 18 | } |
| nothing | 0:aba03316ce9e | 19 | } |
| nothing | 0:aba03316ce9e | 20 | |
| nothing | 0:aba03316ce9e | 21 | void countdown() { |
| nothing | 0:aba03316ce9e | 22 | |
| nothing | 0:aba03316ce9e | 23 | for (counter = 8; counter > 1; counter = counter >> 1) { |
| nothing | 0:aba03316ce9e | 24 | myled1 = counter & 1; |
| nothing | 0:aba03316ce9e | 25 | myled2 = (counter >> 1) & 1; |
| nothing | 0:aba03316ce9e | 26 | myled3 = (counter >> 2) & 1; |
| nothing | 0:aba03316ce9e | 27 | myled4 = (counter >> 3) & 1; |
| nothing | 0:aba03316ce9e | 28 | wait(0.1); |
| nothing | 0:aba03316ce9e | 29 | } |
| nothing | 0:aba03316ce9e | 30 | } |
| nothing | 0:aba03316ce9e | 31 | |
| nothing | 0:aba03316ce9e | 32 | int main() { |
| nothing | 0:aba03316ce9e | 33 | while (1) { |
| nothing | 0:aba03316ce9e | 34 | countup(); |
| nothing | 0:aba03316ce9e | 35 | countdown(); |
| nothing | 0:aba03316ce9e | 36 | } |
| nothing | 0:aba03316ce9e | 37 | } |
| nothing | 0:aba03316ce9e | 38 | |
| nothing | 0:aba03316ce9e | 39 | |
| nothing | 0:aba03316ce9e | 40 | |
| nothing | 0:aba03316ce9e | 41 | |
| nothing | 0:aba03316ce9e | 42 | |
| nothing | 0:aba03316ce9e | 43 | |
| nothing | 0:aba03316ce9e | 44 | |
| nothing | 0:aba03316ce9e | 45 |