![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
...
main.cpp@4:78a9354fcee8, 2017-05-29 (annotated)
- Committer:
- vermaelen
- Date:
- Mon May 29 16:50:40 2017 +0000
- Revision:
- 4:78a9354fcee8
- Parent:
- 3:b91371837109
- Child:
- 6:5f7df5c74a77
VERSION QUI FONCTIONNE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vermaelen | 0:dcb865a03d57 | 1 | #include "mbed.h" |
vermaelen | 2:82b72fa8dbcd | 2 | #include "fct.h" |
vermaelen | 3:b91371837109 | 3 | BusOut ledsetat(p12,p13); |
vermaelen | 0:dcb865a03d57 | 4 | |
vermaelen | 0:dcb865a03d57 | 5 | int main() |
vermaelen | 0:dcb865a03d57 | 6 | { |
vermaelen | 2:82b72fa8dbcd | 7 | int etat=0; |
vermaelen | 2:82b72fa8dbcd | 8 | init(); |
vermaelen | 0:dcb865a03d57 | 9 | while(1) { |
vermaelen | 4:78a9354fcee8 | 10 | // printf("etat=%d US1=%.0f US2=%.0f US3=%.0f erreur=%.0f AN1=%.0f AN2=%.0f cmdD=%.0f cmdG=%.0f\n\r",etat,US1,US2,US3,(US2-US1),AN1,AN2,cmdD,cmdG); |
vermaelen | 2:82b72fa8dbcd | 11 | //wait(0.05); |
vermaelen | 3:b91371837109 | 12 | ledsetat.write(etat); |
vermaelen | 2:82b72fa8dbcd | 13 | switch(etat) { |
vermaelen | 2:82b72fa8dbcd | 14 | case 0 : |
vermaelen | 3:b91371837109 | 15 | if((AN2>10 && AN2<20) || US3<13) { |
vermaelen | 2:82b72fa8dbcd | 16 | etat=1; |
vermaelen | 2:82b72fa8dbcd | 17 | stopMotor(); |
vermaelen | 2:82b72fa8dbcd | 18 | } |
vermaelen | 3:b91371837109 | 19 | if(US2>100 && US1<40) { |
vermaelen | 3:b91371837109 | 20 | etat=2; |
vermaelen | 3:b91371837109 | 21 | stopMotor(); |
vermaelen | 3:b91371837109 | 22 | } |
vermaelen | 2:82b72fa8dbcd | 23 | break; |
vermaelen | 2:82b72fa8dbcd | 24 | case 1 : |
vermaelen | 4:78a9354fcee8 | 25 | if(US2>100 && US1<40) { |
vermaelen | 4:78a9354fcee8 | 26 | etat=2; |
vermaelen | 4:78a9354fcee8 | 27 | stopMotor(); |
vermaelen | 4:78a9354fcee8 | 28 | } |
vermaelen | 2:82b72fa8dbcd | 29 | if(AN2>30) { |
vermaelen | 2:82b72fa8dbcd | 30 | etat=0; |
vermaelen | 3:b91371837109 | 31 | t2.start(); |
vermaelen | 3:b91371837109 | 32 | t2.reset(); |
vermaelen | 2:82b72fa8dbcd | 33 | stopMotor(); |
vermaelen | 2:82b72fa8dbcd | 34 | } |
vermaelen | 4:78a9354fcee8 | 35 | |
vermaelen | 2:82b72fa8dbcd | 36 | break; |
vermaelen | 3:b91371837109 | 37 | case 2 : |
vermaelen | 3:b91371837109 | 38 | if((AN2>10 && AN2<20) || US3<13) { |
vermaelen | 3:b91371837109 | 39 | etat=1; |
vermaelen | 3:b91371837109 | 40 | stopMotor(); |
vermaelen | 3:b91371837109 | 41 | } |
vermaelen | 4:78a9354fcee8 | 42 | if(t2.read()>4) { |
vermaelen | 3:b91371837109 | 43 | etat=0; |
vermaelen | 3:b91371837109 | 44 | } |
vermaelen | 3:b91371837109 | 45 | break; |
vermaelen | 2:82b72fa8dbcd | 46 | } |
vermaelen | 2:82b72fa8dbcd | 47 | switch(etat) { |
vermaelen | 2:82b72fa8dbcd | 48 | case 0 : |
vermaelen | 2:82b72fa8dbcd | 49 | suivi_mur(); |
vermaelen | 2:82b72fa8dbcd | 50 | break; |
vermaelen | 2:82b72fa8dbcd | 51 | case 1 : |
vermaelen | 2:82b72fa8dbcd | 52 | rotation_horaire(); |
vermaelen | 2:82b72fa8dbcd | 53 | break; |
vermaelen | 3:b91371837109 | 54 | case 2 : |
vermaelen | 3:b91371837109 | 55 | contournement(); |
vermaelen | 3:b91371837109 | 56 | break; |
vermaelen | 2:82b72fa8dbcd | 57 | } |
vermaelen | 1:714fd6b732be | 58 | |
vermaelen | 0:dcb865a03d57 | 59 | } |
vermaelen | 0:dcb865a03d57 | 60 | } |