![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Test 1
main.cpp@0:671f83c726f2, 2019-11-26 (annotated)
- Committer:
- benbrou06
- Date:
- Tue Nov 26 12:39:38 2019 +0000
- Revision:
- 0:671f83c726f2
premiere version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benbrou06 | 0:671f83c726f2 | 1 | //#define Passe_Temps1 |
benbrou06 | 0:671f83c726f2 | 2 | #ifdef Passe_Temps1 |
benbrou06 | 0:671f83c726f2 | 3 | |
benbrou06 | 0:671f83c726f2 | 4 | #include "mbed.h" |
benbrou06 | 0:671f83c726f2 | 5 | #include "info1.h" |
benbrou06 | 0:671f83c726f2 | 6 | |
benbrou06 | 0:671f83c726f2 | 7 | void Led(int); |
benbrou06 | 0:671f83c726f2 | 8 | |
benbrou06 | 0:671f83c726f2 | 9 | int main() |
benbrou06 | 0:671f83c726f2 | 10 | { |
benbrou06 | 0:671f83c726f2 | 11 | PwmOut led1( LED_RED ); |
benbrou06 | 0:671f83c726f2 | 12 | PwmOut led2( LED_GREEN ); |
benbrou06 | 0:671f83c726f2 | 13 | PwmOut led3( LED_BLUE ); |
benbrou06 | 0:671f83c726f2 | 14 | led1.period_us(100); |
benbrou06 | 0:671f83c726f2 | 15 | led2.period_us(100); |
benbrou06 | 0:671f83c726f2 | 16 | led3.period_us(100); |
benbrou06 | 0:671f83c726f2 | 17 | int val1,val2,etat=0,Allumer; |
benbrou06 | 0:671f83c726f2 | 18 | led1 = 1; |
benbrou06 | 0:671f83c726f2 | 19 | led2 = 1; |
benbrou06 | 0:671f83c726f2 | 20 | led3 = 1; |
benbrou06 | 0:671f83c726f2 | 21 | |
benbrou06 | 0:671f83c726f2 | 22 | while (1) |
benbrou06 | 0:671f83c726f2 | 23 | { |
benbrou06 | 0:671f83c726f2 | 24 | appui_ana (&val1,&val2,0.5); |
benbrou06 | 0:671f83c726f2 | 25 | |
benbrou06 | 0:671f83c726f2 | 26 | |
benbrou06 | 0:671f83c726f2 | 27 | if (val1==1) |
benbrou06 | 0:671f83c726f2 | 28 | { |
benbrou06 | 0:671f83c726f2 | 29 | Allumer=1; |
benbrou06 | 0:671f83c726f2 | 30 | do |
benbrou06 | 0:671f83c726f2 | 31 | { |
benbrou06 | 0:671f83c726f2 | 32 | switch(etat) |
benbrou06 | 0:671f83c726f2 | 33 | { |
benbrou06 | 0:671f83c726f2 | 34 | case 0 : etat =1; break; |
benbrou06 | 0:671f83c726f2 | 35 | case 1 : etat =2; break; |
benbrou06 | 0:671f83c726f2 | 36 | case 2 : etat =3; break; |
benbrou06 | 0:671f83c726f2 | 37 | case 3 : etat =4; break; |
benbrou06 | 0:671f83c726f2 | 38 | case 4 : etat =5; break; |
benbrou06 | 0:671f83c726f2 | 39 | case 5 : etat =6; break; |
benbrou06 | 0:671f83c726f2 | 40 | case 6 : etat =0; break; |
benbrou06 | 0:671f83c726f2 | 41 | } |
benbrou06 | 0:671f83c726f2 | 42 | |
benbrou06 | 0:671f83c726f2 | 43 | |
benbrou06 | 0:671f83c726f2 | 44 | switch(etat) |
benbrou06 | 0:671f83c726f2 | 45 | { |
benbrou06 | 0:671f83c726f2 | 46 | case 0 : led1 = 1; led2 = 1; led3 = 1; break; |
benbrou06 | 0:671f83c726f2 | 47 | case 1 : led1 = 1; led2 = 0; led3 = 1; break; |
benbrou06 | 0:671f83c726f2 | 48 | case 2 : led1 = 0; led2 = 0; led3 = 1; break; |
benbrou06 | 0:671f83c726f2 | 49 | case 3 : led1 = 1; led2 = 1; led3 = 0; break; |
benbrou06 | 0:671f83c726f2 | 50 | case 4 : led1 = 1; led2 = 0; led3 = 0; break; |
benbrou06 | 0:671f83c726f2 | 51 | case 5 : led1 = 0; led2 = 1; led3 = 1; break; |
benbrou06 | 0:671f83c726f2 | 52 | case 6 : led1 = 0; led2 = 1; led3 = 0; break; |
benbrou06 | 0:671f83c726f2 | 53 | } |
benbrou06 | 0:671f83c726f2 | 54 | |
benbrou06 | 0:671f83c726f2 | 55 | appui_ana (&val1,&val2,0.5); |
benbrou06 | 0:671f83c726f2 | 56 | |
benbrou06 | 0:671f83c726f2 | 57 | if (val2==1) |
benbrou06 | 0:671f83c726f2 | 58 | {led1 = 1; led2 = 1; led3 = 1;Allumer=0;etat=0;} |
benbrou06 | 0:671f83c726f2 | 59 | |
benbrou06 | 0:671f83c726f2 | 60 | wait_ms(800); |
benbrou06 | 0:671f83c726f2 | 61 | } |
benbrou06 | 0:671f83c726f2 | 62 | while(Allumer==1); |
benbrou06 | 0:671f83c726f2 | 63 | } |
benbrou06 | 0:671f83c726f2 | 64 | |
benbrou06 | 0:671f83c726f2 | 65 | } |
benbrou06 | 0:671f83c726f2 | 66 | } |
benbrou06 | 0:671f83c726f2 | 67 | |
benbrou06 | 0:671f83c726f2 | 68 | #endif |