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:a0ff9388a0b8, 2010-08-26 (annotated)
- Committer:
- 4180_1
- Date:
- Thu Aug 26 16:51:51 2010 +0000
- Revision:
- 0:a0ff9388a0b8
- Child:
- 1:13ed59a7806b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:a0ff9388a0b8 | 1 | #include "mbed.h" |
4180_1 | 0:a0ff9388a0b8 | 2 | // Cylon style LED scanner |
4180_1 | 0:a0ff9388a0b8 | 3 | BusOut led_state(LED1, LED2, LED3, LED4); |
4180_1 | 0:a0ff9388a0b8 | 4 | |
4180_1 | 0:a0ff9388a0b8 | 5 | int main() { |
4180_1 | 0:a0ff9388a0b8 | 6 | int i = 0; |
4180_1 | 0:a0ff9388a0b8 | 7 | // initinal LED state |
4180_1 | 0:a0ff9388a0b8 | 8 | led_state = 0x1; |
4180_1 | 0:a0ff9388a0b8 | 9 | while (1) { |
4180_1 | 0:a0ff9388a0b8 | 10 | // loop through all states |
4180_1 | 0:a0ff9388a0b8 | 11 | for (i=0; i<6; i++) { |
4180_1 | 0:a0ff9388a0b8 | 12 | if (i<3) |
4180_1 | 0:a0ff9388a0b8 | 13 | // shift left 1 bit until high LED set |
4180_1 | 0:a0ff9388a0b8 | 14 | led_state = led_state << 1; |
4180_1 | 0:a0ff9388a0b8 | 15 | else |
4180_1 | 0:a0ff9388a0b8 | 16 | // then reverse and shift back to right 1 bit |
4180_1 | 0:a0ff9388a0b8 | 17 | led_state = led_state >> 1; |
4180_1 | 0:a0ff9388a0b8 | 18 | // time delay .1s to slow down display |
4180_1 | 0:a0ff9388a0b8 | 19 | wait(0.1); |
4180_1 | 0:a0ff9388a0b8 | 20 | } |
4180_1 | 0:a0ff9388a0b8 | 21 | } |
4180_1 | 0:a0ff9388a0b8 | 22 | } |