Étape 3: Partie du Code
int curr_value = 0 ;
int acc_value = 0 ;
float disp_res ;
flotteur d’alimentation = 4.91 ;
float coeff_v100 = 1,01 ;
volatile unsigned long last_millis = 0 ;
void setup()
{
Serial.Begin(9600) ;
}
void loop()
{
V_100() ;
}
Sub V_100()
{
Serial.Print ("compteur-V V = < 100V") ;
Serial.println ("* mode voltmètre - plage de 0 - 100 V * ») ;
voltage_meas() ;
}
Sub voltage_meas()
{
acc_value = 0 ;
pour (int i = 0; i < = 15; i ++)
{
curr_value = analogRead(A0) ;
acc_value = acc_value + curr_value ;
}
curr_value = int(acc_value/16) ;
disp_res = (curr_value * d’alimentation * 20) / 1024 * coeff_v100 ;
Serial.Print ("V =") ;
Serial.Print (disp_res, 2) ;
Serial.Print ("V") ;
Serial.Print ("* V =") ;
Serial.Print (disp_res, 2) ;
Serial.println ("V") ;
Delay(250) ;
}