Hello all,
I have a problem with this code, pease help me:
int opto= 13;
int etat = 0;
int ancien_etat = 0;
double chrono = 0;
long chrono_depart = 0;
long duree_test = 15000;
int nb_chgt = 0;
double vitesse;
double nb_litre;
char affiche = 0;
int cardispo = 0;
int debut = 0;
char carlu = 0;
void setup ()
{
Serial.begin (9600);
pinMode(opto,INPUT);
}
int fonction()
{
chrono_depart = millis();
return chrono_depart;
}
void loop()
{
if(carlu == 0)
{
Serial.println("Voulez-vous connaitre votre consommation d'eau instantannee?");
Serial.println("Saisissez 1 pour OUI ou 0 pour NON");
Serial.println("");
cardispo = Serial.available();
while(cardispo > 0)
{
carlu = Serial.read();
cardispo = Serial.available();
}
}
else if(1)
{
etat = digitalRead(opto);
chrono = millis ();
int fonction ();
}
else if (carlu > 0)
{
Serial.println("Veuillez patienter 15 secondes.");
Serial.println("");
if (chrono - chrono_depart < duree_test)
{
if (etat != ancien_etat)
{
nb_chgt = nb_chgt + 1 ;
ancien_etat = etat;
}
}
}
else
{
if (affiche == 1)
{
vitesse = nb_chgt * 0.4;
chrono = chrono / 15000;
nb_litre = vitesse * chrono * 0.1 /4;
Serial.print("Vitesse: ");
Serial.print(vitesse);
Serial.print("tours/min.");
Serial.println("");
Serial.print("Votre consommation d'eau instantannee est de : ");
Serial.print(nb_litre);
Serial.println(" litres d'eau.");
Serial.println("");
affiche = 2;
}
}
}