code petit robot pour homologation
Fork of CRAC-Strat_2017_V2 by
peripheriques/capteurs.cpp@18:cc5fec34ed9c, 2017-05-22 (annotated)
- Committer:
- ClementBreteau
- Date:
- Mon May 22 15:01:49 2017 +0000
- Revision:
- 18:cc5fec34ed9c
- Parent:
- 16:7321fb3bb396
v2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ClementBreteau | 16:7321fb3bb396 | 1 | #include "peripheriques.h" |
ClementBreteau | 16:7321fb3bb396 | 2 | |
ClementBreteau | 16:7321fb3bb396 | 3 | AnalogIn cptGauche(p20); |
ClementBreteau | 16:7321fb3bb396 | 4 | AnalogIn cptDroit(p19); |
ClementBreteau | 16:7321fb3bb396 | 5 | |
ClementBreteau | 16:7321fb3bb396 | 6 | DigitalIn pressionGauche(p23); |
ClementBreteau | 16:7321fb3bb396 | 7 | DigitalIn pressionDroit(p24); |
ClementBreteau | 16:7321fb3bb396 | 8 | |
ClementBreteau | 16:7321fb3bb396 | 9 | AnalogIn telemetre(p15); |
ClementBreteau | 16:7321fb3bb396 | 10 | |
ClementBreteau | 16:7321fb3bb396 | 11 | //DigitalIn jack(p25); |
ClementBreteau | 16:7321fb3bb396 | 12 | |
ClementBreteau | 16:7321fb3bb396 | 13 | |
ClementBreteau | 16:7321fb3bb396 | 14 | bool dataCouleurGauche(void){ |
ClementBreteau | 16:7321fb3bb396 | 15 | bool couleurOK = false; |
ClementBreteau | 16:7321fb3bb396 | 16 | if(cptGauche.read() < 0.3){ |
ClementBreteau | 16:7321fb3bb396 | 17 | couleurOK = true; |
ClementBreteau | 16:7321fb3bb396 | 18 | } |
ClementBreteau | 16:7321fb3bb396 | 19 | return couleurOK; |
ClementBreteau | 16:7321fb3bb396 | 20 | } |
ClementBreteau | 16:7321fb3bb396 | 21 | |
ClementBreteau | 16:7321fb3bb396 | 22 | bool dataCouleurDroit(void){ |
ClementBreteau | 16:7321fb3bb396 | 23 | bool couleurOK = false; |
ClementBreteau | 16:7321fb3bb396 | 24 | if(cptDroit.read() < 0.3){ |
ClementBreteau | 16:7321fb3bb396 | 25 | couleurOK = true; |
ClementBreteau | 16:7321fb3bb396 | 26 | } |
ClementBreteau | 16:7321fb3bb396 | 27 | return couleurOK; |
ClementBreteau | 16:7321fb3bb396 | 28 | } |
ClementBreteau | 16:7321fb3bb396 | 29 | |
ClementBreteau | 18:cc5fec34ed9c | 30 | unsigned short dataTelemetre(void){ |
ClementBreteau | 18:cc5fec34ed9c | 31 | float distance = telemetre.read()*3.3*1159.6-687.5+98; |
ClementBreteau | 18:cc5fec34ed9c | 32 | return (unsigned short)distance; |
ClementBreteau | 16:7321fb3bb396 | 33 | } |
ClementBreteau | 16:7321fb3bb396 | 34 | |
ClementBreteau | 16:7321fb3bb396 | 35 | bool dataPressionGauche(void){ |
ClementBreteau | 16:7321fb3bb396 | 36 | if(cptGauche.read())return true; |
ClementBreteau | 16:7321fb3bb396 | 37 | else return false; |
ClementBreteau | 16:7321fb3bb396 | 38 | } |
ClementBreteau | 16:7321fb3bb396 | 39 | |
ClementBreteau | 16:7321fb3bb396 | 40 | bool dataPressionDroit(void){ |
ClementBreteau | 16:7321fb3bb396 | 41 | if(cptDroit.read())return true; |
ClementBreteau | 16:7321fb3bb396 | 42 | else return false; |
ClementBreteau | 16:7321fb3bb396 | 43 | } |