schneider françois
/
BaseF411RE-v2
base
main.cpp@0:5a82eeefcf10, 2020-11-16 (annotated)
- Committer:
- schnf30
- Date:
- Mon Nov 16 10:49:53 2020 +0000
- Revision:
- 0:5a82eeefcf10
Base
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
schnf30 | 0:5a82eeefcf10 | 1 | #include "mbed.h" |
schnf30 | 0:5a82eeefcf10 | 2 | #include "C12832.h" |
schnf30 | 0:5a82eeefcf10 | 3 | #include "platform/mbed_thread.h" |
schnf30 | 0:5a82eeefcf10 | 4 | |
schnf30 | 0:5a82eeefcf10 | 5 | // Rate acquisition |
schnf30 | 0:5a82eeefcf10 | 6 | #define BLINKING_RATE_MS 500 |
schnf30 | 0:5a82eeefcf10 | 7 | C12832 lcd(D11, D13, D12, D7, D10); |
schnf30 | 0:5a82eeefcf10 | 8 | AnalogIn pot1 (A0); |
schnf30 | 0:5a82eeefcf10 | 9 | AnalogIn pot2 (A1); |
schnf30 | 0:5a82eeefcf10 | 10 | |
schnf30 | 0:5a82eeefcf10 | 11 | int main() |
schnf30 | 0:5a82eeefcf10 | 12 | { |
schnf30 | 0:5a82eeefcf10 | 13 | float Entree1,Entree2; |
schnf30 | 0:5a82eeefcf10 | 14 | while (true) { |
schnf30 | 0:5a82eeefcf10 | 15 | // acqusition des entrees |
schnf30 | 0:5a82eeefcf10 | 16 | Entree1 = 3.3*pot1.read(); |
schnf30 | 0:5a82eeefcf10 | 17 | Entree2 = 3.3*pot2.read(); |
schnf30 | 0:5a82eeefcf10 | 18 | // traitement de l entree1 |
schnf30 | 0:5a82eeefcf10 | 19 | |
schnf30 | 0:5a82eeefcf10 | 20 | lcd.cls(); |
schnf30 | 0:5a82eeefcf10 | 21 | lcd.locate(0,3); |
schnf30 | 0:5a82eeefcf10 | 22 | if ( Entree1 < 0.36 ) { |
schnf30 | 0:5a82eeefcf10 | 23 | lcd.printf("COURT CIRCUIT\n"); |
schnf30 | 0:5a82eeefcf10 | 24 | } else if ( Entree1 < 0.88 ) { |
schnf30 | 0:5a82eeefcf10 | 25 | lcd.printf("ANOMALIE\n"); |
schnf30 | 0:5a82eeefcf10 | 26 | } else if ( Entree1 < 1.41 ) { |
schnf30 | 0:5a82eeefcf10 | 27 | lcd.printf("PAS ANOMALIE\n"); |
schnf30 | 0:5a82eeefcf10 | 28 | } else { |
schnf30 | 0:5a82eeefcf10 | 29 | lcd.printf("COUPE DE CABLE\n"); |
schnf30 | 0:5a82eeefcf10 | 30 | } |
schnf30 | 0:5a82eeefcf10 | 31 | |
schnf30 | 0:5a82eeefcf10 | 32 | lcd.locate(0,14); |
schnf30 | 0:5a82eeefcf10 | 33 | lcd.printf("Pot 2 = %.2f", Entree2); |
schnf30 | 0:5a82eeefcf10 | 34 | |
schnf30 | 0:5a82eeefcf10 | 35 | thread_sleep_for(BLINKING_RATE_MS); //wait.... |
schnf30 | 0:5a82eeefcf10 | 36 | } |
schnf30 | 0:5a82eeefcf10 | 37 | } |