Grattepanche aymeric
/
ex2
ex 2
exo2.cpp@0:13a0ec0e32cf, 2018-12-11 (annotated)
- Committer:
- aymeric29
- Date:
- Tue Dec 11 08:35:23 2018 +0000
- Revision:
- 0:13a0ec0e32cf
S
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aymeric29 | 0:13a0ec0e32cf | 1 | |
aymeric29 | 0:13a0ec0e32cf | 2 | #include "mbed.h" |
aymeric29 | 0:13a0ec0e32cf | 3 | DigitalOut L[8]={PB_1,PB_2,PB_10,PB_11,PB_12,PB_13,PB_14,PB_15}; |
aymeric29 | 0:13a0ec0e32cf | 4 | void set_8Dels(uint8_t position){ |
aymeric29 | 0:13a0ec0e32cf | 5 | while(1){ |
aymeric29 | 0:13a0ec0e32cf | 6 | L[position]=1; |
aymeric29 | 0:13a0ec0e32cf | 7 | wait(0.2); |
aymeric29 | 0:13a0ec0e32cf | 8 | L[position]=0; |
aymeric29 | 0:13a0ec0e32cf | 9 | wait(0.2); |
aymeric29 | 0:13a0ec0e32cf | 10 | |
aymeric29 | 0:13a0ec0e32cf | 11 | } |
aymeric29 | 0:13a0ec0e32cf | 12 | } |
aymeric29 | 0:13a0ec0e32cf | 13 | |
aymeric29 | 0:13a0ec0e32cf | 14 | int main() { |
aymeric29 | 0:13a0ec0e32cf | 15 | int compteur,sens; |
aymeric29 | 0:13a0ec0e32cf | 16 | compteur=0; |
aymeric29 | 0:13a0ec0e32cf | 17 | sens=0; |
aymeric29 | 0:13a0ec0e32cf | 18 | while(1){ |
aymeric29 | 0:13a0ec0e32cf | 19 | wait(0.2); |
aymeric29 | 0:13a0ec0e32cf | 20 | if (sens==0){ |
aymeric29 | 0:13a0ec0e32cf | 21 | compteur++; |
aymeric29 | 0:13a0ec0e32cf | 22 | if(compteur==9){ |
aymeric29 | 0:13a0ec0e32cf | 23 | sens=1; |
aymeric29 | 0:13a0ec0e32cf | 24 | } |
aymeric29 | 0:13a0ec0e32cf | 25 | } |
aymeric29 | 0:13a0ec0e32cf | 26 | if(sens==1){ |
aymeric29 | 0:13a0ec0e32cf | 27 | compteur--; |
aymeric29 | 0:13a0ec0e32cf | 28 | if(compteur==0){ |
aymeric29 | 0:13a0ec0e32cf | 29 | sens=0; |
aymeric29 | 0:13a0ec0e32cf | 30 | } |
aymeric29 | 0:13a0ec0e32cf | 31 | } |
aymeric29 | 0:13a0ec0e32cf | 32 | set_8Dels(compteur); |
aymeric29 | 0:13a0ec0e32cf | 33 | } |
aymeric29 | 0:13a0ec0e32cf | 34 | } |