Noah Proust
/
centrale_alarme_v1
vh
main.cpp
- Committer:
- arkadia
- Date:
- 2021-06-08
- Revision:
- 0:d7df74440bf6
File content as of revision 0:d7df74440bf6:
/* Programme centrale d'alarme V1_0 Le 16/12/2020 Par Simon Delcroix */ // On ajoute entree 1 #include "mbed.h" #include "platform/mbed_thread.h" #include "C12832.h" // Blinking rate in milliseconds #define BLINKING_RATE_MS 500 Serial pc(USBTX,USBRX); AnalogIn pot1 (A0); C12832 lcd(D11, D13, D12, D7, D10); /* fonction qui traite les entrees en entree : valeur de l'entree en sortie : etat entree Cc : Court circuit An : Anomalie Nl : normal Cp : cable coupoe */ #define VNl 1.41 // en dessous pas anomalie #define VAn 0.88 // en dessous Anomalie #define VCc 0.36 // en dessous cable cc // au dessus de VNl Cable coupe int resultat; PwmOut led (D5); PwmOut spkr(D6); int main() { while(true) { float Entree1; float cc = 200; float an = 500; float cp = 800; Entree1 = 5*pot1.read(); pc.printf("Entree 1 =%f\n\r",Entree1); if (Entree1 < VCc) { lcd.locate(0, 3); lcd.printf("Entree 1 : Court circuit"); led.write(0.15); led.period(1); spkr.period(1.0/cc); spkr=0.5; thread_sleep_for(0.2); } else if (Entree1 < VAn) { lcd.locate(0, 3); lcd.printf("Entree 1 : Anomalie "); led.write(0.05); led.period(1); spkr.period(1.0/an); spkr=0.5; thread_sleep_for(0.2); } else if (Entree1 < VNl) { lcd.locate(0, 3); lcd.printf("Entree 1 : Etat normal "); led.write(1); led.period(1); spkr=0.0; } else { lcd.locate(0, 3); lcd.printf("Entree 1 : Cable coupe "); led.write(0.1); led.period(1); spkr.period(1.0/cp); spkr=0.5; thread_sleep_for(0.2); } } }