test cli
Dependencies: mbed-os-example-mbed5-lorawan
Fork of Projet_de_bachelor_code by
Sensors.cpp
00001 #include "Sensors.h" 00002 #include "mbed.h" 00003 00004 int SENSORS::current_sensor(){ 00005 float courant_mes; 00006 int courant_lu; 00007 DigitalOut alim_control(PA_10); 00008 AnalogIn courant(PA_5); 00009 alim_control = 1; 00010 courant_mes = courant.read(); 00011 courant_lu = courant_mes * 250; 00012 printf("courant = %f = %d mA\n", courant_mes,courant_lu); 00013 return courant_lu; 00014 } 00015 00016 int SENSORS::transducer_sensor(){ 00017 float transducteur_volt; 00018 int transducteur_pos; 00019 AnalogIn transducteur(PA_2); 00020 DigitalOut alim_control(PA_10); 00021 DigitalOut control_trans(PB_5); 00022 DigitalOut control_QSD(PA_9); 00023 control_QSD = 0; 00024 alim_control=0; 00025 control_trans=1; 00026 wait(2.0); 00027 transducteur_volt = transducteur.read(); 00028 transducteur_pos = transducteur_volt; 00029 return transducteur_pos; 00030 } 00031 00032 int SENSORS::vbat_sensor(){ 00033 float bat_mes; 00034 int bat_lu; 00035 AnalogIn tension_bat(PA_4); 00036 int u_bat; 00037 DigitalOut alim_control(PA_10); 00038 DigitalOut control_trans(PB_5); 00039 DigitalOut control_QSD(PA_9); 00040 bat_mes = tension_bat.read(); 00041 DigitalOut led(PA_11); 00042 bat_lu = bat_mes * 1800; 00043 if(bat_lu<1700) 00044 { 00045 u_bat = 1; 00046 led = 1; 00047 } 00048 else 00049 { 00050 u_bat = 0; 00051 led = 0; 00052 } 00053 return u_bat; 00054 00055 }
Generated on Thu Jul 14 2022 11:45:28 by 1.7.2