thibault lottin
/
TP1_exo4
TP1_exo4
main.cpp@0:e8cbbc2bf290, 2014-10-23 (annotated)
- Committer:
- mbedo
- Date:
- Thu Oct 23 12:12:09 2014 +0000
- Revision:
- 0:e8cbbc2bf290
TP1_exo4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedo | 0:e8cbbc2bf290 | 1 | #include "mbed.h" |
mbedo | 0:e8cbbc2bf290 | 2 | |
mbedo | 0:e8cbbc2bf290 | 3 | PwmOut led(LED1); // on initialise nos 4 leds en utilisant l'interface PwmOut |
mbedo | 0:e8cbbc2bf290 | 4 | PwmOut led2(LED2); |
mbedo | 0:e8cbbc2bf290 | 5 | PwmOut led3(LED3); |
mbedo | 0:e8cbbc2bf290 | 6 | PwmOut led4(LED4); |
mbedo | 0:e8cbbc2bf290 | 7 | |
mbedo | 0:e8cbbc2bf290 | 8 | int main() { |
mbedo | 0:e8cbbc2bf290 | 9 | while(1) { |
mbedo | 0:e8cbbc2bf290 | 10 | for(float p = 0.0f; p < 1.0f; p += 0.1f) { // la led1 s'allume progressivement |
mbedo | 0:e8cbbc2bf290 | 11 | led = p; // |
mbedo | 0:e8cbbc2bf290 | 12 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 13 | } |
mbedo | 0:e8cbbc2bf290 | 14 | for(float p = 1.0f; p >= 0.0f; p -= 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 15 | led = p; |
mbedo | 0:e8cbbc2bf290 | 16 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 17 | led=0; |
mbedo | 0:e8cbbc2bf290 | 18 | |
mbedo | 0:e8cbbc2bf290 | 19 | } |
mbedo | 0:e8cbbc2bf290 | 20 | for(float p = 0.0f; p < 1.0f; p += 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 21 | led2 = p; |
mbedo | 0:e8cbbc2bf290 | 22 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 23 | } |
mbedo | 0:e8cbbc2bf290 | 24 | |
mbedo | 0:e8cbbc2bf290 | 25 | for(float p = 1.0f; p >= 0.0f; p -= 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 26 | led2 = p; |
mbedo | 0:e8cbbc2bf290 | 27 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 28 | led2=0; |
mbedo | 0:e8cbbc2bf290 | 29 | |
mbedo | 0:e8cbbc2bf290 | 30 | } |
mbedo | 0:e8cbbc2bf290 | 31 | for(float p = 0.0f; p < 1.0f; p += 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 32 | led3 = p; |
mbedo | 0:e8cbbc2bf290 | 33 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 34 | } |
mbedo | 0:e8cbbc2bf290 | 35 | for(float p = 1.0f; p >= 0.0f; p -= 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 36 | led3 = p; |
mbedo | 0:e8cbbc2bf290 | 37 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 38 | led3=0; |
mbedo | 0:e8cbbc2bf290 | 39 | |
mbedo | 0:e8cbbc2bf290 | 40 | } |
mbedo | 0:e8cbbc2bf290 | 41 | for(float p = 0.0f; p < 1.0f; p += 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 42 | led4 = p; |
mbedo | 0:e8cbbc2bf290 | 43 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 44 | } |
mbedo | 0:e8cbbc2bf290 | 45 | for(float p = 1.0f; p >= 0.0f; p -= 0.1f) { |
mbedo | 0:e8cbbc2bf290 | 46 | led4 = p; |
mbedo | 0:e8cbbc2bf290 | 47 | wait(0.1); |
mbedo | 0:e8cbbc2bf290 | 48 | led4=0; |
mbedo | 0:e8cbbc2bf290 | 49 | |
mbedo | 0:e8cbbc2bf290 | 50 | } |
mbedo | 0:e8cbbc2bf290 | 51 | } |
mbedo | 0:e8cbbc2bf290 | 52 | } |
mbedo | 0:e8cbbc2bf290 | 53 |