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:adb9fcb3b1bb, 2010-05-09 (annotated)
- Committer:
- leonous
- Date:
- Sun May 09 01:25:51 2010 +0000
- Revision:
- 0:adb9fcb3b1bb
- Child:
- 1:6c8d46a9c3c9
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| leonous | 0:adb9fcb3b1bb | 1 | #include "mbed.h" |
| leonous | 0:adb9fcb3b1bb | 2 | |
| leonous | 0:adb9fcb3b1bb | 3 | DigitalOut myled1(LED1); |
| leonous | 0:adb9fcb3b1bb | 4 | DigitalOut myled2(LED2); |
| leonous | 0:adb9fcb3b1bb | 5 | DigitalOut myled3(LED3); |
| leonous | 0:adb9fcb3b1bb | 6 | DigitalOut myled4(LED4); |
| leonous | 0:adb9fcb3b1bb | 7 | |
| leonous | 0:adb9fcb3b1bb | 8 | void update_leds (int myleds) |
| leonous | 0:adb9fcb3b1bb | 9 | { |
| leonous | 0:adb9fcb3b1bb | 10 | myled1 = myleds & 1; |
| leonous | 0:adb9fcb3b1bb | 11 | myled2 = (myleds & 2) >> 1; |
| leonous | 0:adb9fcb3b1bb | 12 | myled3 = (myleds & 4) >> 2; |
| leonous | 0:adb9fcb3b1bb | 13 | myled4 = (myleds & 8) >> 3; |
| leonous | 0:adb9fcb3b1bb | 14 | } |
| leonous | 0:adb9fcb3b1bb | 15 | |
| leonous | 0:adb9fcb3b1bb | 16 | int main() |
| leonous | 0:adb9fcb3b1bb | 17 | { |
| leonous | 0:adb9fcb3b1bb | 18 | int count, count_up = 0; |
| leonous | 0:adb9fcb3b1bb | 19 | float count_interval = 1.0; |
| leonous | 0:adb9fcb3b1bb | 20 | count = 0; |
| leonous | 0:adb9fcb3b1bb | 21 | while(1) |
| leonous | 0:adb9fcb3b1bb | 22 | { |
| leonous | 0:adb9fcb3b1bb | 23 | update_leds (count); |
| leonous | 0:adb9fcb3b1bb | 24 | count++; |
| leonous | 0:adb9fcb3b1bb | 25 | wait(count_interval); |
| leonous | 0:adb9fcb3b1bb | 26 | |
| leonous | 0:adb9fcb3b1bb | 27 | if (count_up && count % 16 == 0) |
| leonous | 0:adb9fcb3b1bb | 28 | count_interval *= 2; |
| leonous | 0:adb9fcb3b1bb | 29 | else if (count % 16 == 0) |
| leonous | 0:adb9fcb3b1bb | 30 | count_interval /= 2; |
| leonous | 0:adb9fcb3b1bb | 31 | |
| leonous | 0:adb9fcb3b1bb | 32 | if (count % 256 == 0) |
| leonous | 0:adb9fcb3b1bb | 33 | count_up = ~ count_up; |
| leonous | 0:adb9fcb3b1bb | 34 | } |
| leonous | 0:adb9fcb3b1bb | 35 | } |