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:c606bb1acbdc, 2010-10-29 (annotated)
- Committer:
- daniogenes
- Date:
- Fri Oct 29 18:55:33 2010 +0000
- Revision:
- 0:c606bb1acbdc
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| daniogenes | 0:c606bb1acbdc | 1 | #include "mbed.h" |
| daniogenes | 0:c606bb1acbdc | 2 | |
| daniogenes | 0:c606bb1acbdc | 3 | // a flashlight with 4 Leds like the KID in Nightrider |
| daniogenes | 0:c606bb1acbdc | 4 | |
| daniogenes | 0:c606bb1acbdc | 5 | PwmOut led_1(LED1); |
| daniogenes | 0:c606bb1acbdc | 6 | PwmOut led_2(LED2); |
| daniogenes | 0:c606bb1acbdc | 7 | PwmOut led_3(LED3); |
| daniogenes | 0:c606bb1acbdc | 8 | PwmOut led_4(LED4); |
| daniogenes | 0:c606bb1acbdc | 9 | |
| daniogenes | 0:c606bb1acbdc | 10 | int main() { |
| daniogenes | 0:c606bb1acbdc | 11 | |
| daniogenes | 0:c606bb1acbdc | 12 | float |
| daniogenes | 0:c606bb1acbdc | 13 | q; |
| daniogenes | 0:c606bb1acbdc | 14 | |
| daniogenes | 0:c606bb1acbdc | 15 | while(1) { |
| daniogenes | 0:c606bb1acbdc | 16 | for(float p = 0.0f; p < 4.0f; p += 0.1f) { |
| daniogenes | 0:c606bb1acbdc | 17 | led_1 = p; |
| daniogenes | 0:c606bb1acbdc | 18 | led_2 = p-1.0; |
| daniogenes | 0:c606bb1acbdc | 19 | led_3 = p-2.0; |
| daniogenes | 0:c606bb1acbdc | 20 | led_4 = p-3.0; |
| daniogenes | 0:c606bb1acbdc | 21 | wait(0.01); |
| daniogenes | 0:c606bb1acbdc | 22 | } |
| daniogenes | 0:c606bb1acbdc | 23 | for(float p = 4.0f; p > 0.0f; p -= 0.1f) { |
| daniogenes | 0:c606bb1acbdc | 24 | led_4 = p; |
| daniogenes | 0:c606bb1acbdc | 25 | led_3 = p-1.0; |
| daniogenes | 0:c606bb1acbdc | 26 | led_2 = p-2.0; |
| daniogenes | 0:c606bb1acbdc | 27 | led_1 = p-3.0; |
| daniogenes | 0:c606bb1acbdc | 28 | wait(0.01); |
| daniogenes | 0:c606bb1acbdc | 29 | } |
| daniogenes | 0:c606bb1acbdc | 30 | for(float p = 0.0f; p < 4.0f; p += 0.1f) { |
| daniogenes | 0:c606bb1acbdc | 31 | led_4 = p; |
| daniogenes | 0:c606bb1acbdc | 32 | led_3 = p-1.0; |
| daniogenes | 0:c606bb1acbdc | 33 | led_2 = p-2.0; |
| daniogenes | 0:c606bb1acbdc | 34 | led_1 = p-3.0; |
| daniogenes | 0:c606bb1acbdc | 35 | wait(0.01); |
| daniogenes | 0:c606bb1acbdc | 36 | } |
| daniogenes | 0:c606bb1acbdc | 37 | for(float p = 4.0f; p > 0.0f; p -= 0.1f) { |
| daniogenes | 0:c606bb1acbdc | 38 | led_1 = p; |
| daniogenes | 0:c606bb1acbdc | 39 | led_2 = p-1.0; |
| daniogenes | 0:c606bb1acbdc | 40 | led_3 = p-2.0; |
| daniogenes | 0:c606bb1acbdc | 41 | led_4 = p-3.0; |
| daniogenes | 0:c606bb1acbdc | 42 | wait(0.01); |
| daniogenes | 0:c606bb1acbdc | 43 | } |
| daniogenes | 0:c606bb1acbdc | 44 | } |
| daniogenes | 0:c606bb1acbdc | 45 | } |