La machine à faire le plein automatiquement



Le bazar contient un arduino et des relais:

int sensorPin = A0;     
int sensorValue1 = 0;
int sensorValue2 = 0;




 int cycle_duration=3600; 
 int maxwatersecond=5; //On autorise 5sec de pompage dans une heure (70 sec=1litre)

 int cycletime=0; //Compteur de secondes dans le cycle d'une heure
 int watercount=0; //Compteur de secondes d'alimentation de la pompe



void setup() {
 // declare the ledPin as an OUTPUT:
 Serial.begin(9600);
 pinMode(13, OUTPUT); 
  pinMode(12, OUTPUT); 
  digitalWrite(12, HIGH);
}

void loop() {

 cycletime=0; //Compteur de secondes dans le cycle d'une heure
 watercount=0; //Compteur de secondes d'alimentation de la pompe


 while(cycletime<cycle_duration){
   Serial.println("Cycle: "+String(cycletime)+"/"+String(cycle_duration));
   Serial.println("Water: "+String(watercount)+"/"+String(maxwatersecond));

   boolean is_water=isWater();

    if(!is_water ){
      if(watercount<maxwatersecond){
         enablePump(5);
      }else{
         Serial.println("Max water delivered reached for this cycle"); 
      }
    }
    wait(10);
 }

}



void wait(int sec){
 delay(1000*sec);
 cycletime+=sec;
}

void enablePump(int time){
  Serial.println("Enabling pump for "+String(time)+" sec");
  digitalWrite(12, LOW);
  Serial.println("Pump enabled");
  wait(time);
  digitalWrite(12, HIGH);

  Serial.println("Pump disabled");
  watercount=watercount+time;
  Serial.println("Total pump time in cycle: "+String(watercount)+" sec");

}


boolean isWater(){
 Serial.println("Water level mesurement");
 boolean res=true;
 for(int i=0;i<2;i++){

       //On met l'eau à 0V
       digitalWrite(13, LOW);
       //On mesure
       sensorValue1 = analogRead(sensorPin);   

       //On met l'eau a 5V
       digitalWrite(13, HIGH);
       //On mesure
       sensorValue2 = analogRead(sensorPin);   

       if(sensorValue1 < 100 && sensorValue2>=900){
         res=res & true; 
       }else{
         res=res & false; 
         break;
       }
 }
 if(res)Serial.println("Water level OK"); else Serial.println("!Low water level!");
 return res;

}

 

 

Voila une sortie d'execution d'exemple:

 

Cycle: 0/3600
Water: 0/5
Water level mesurement
Water level OK
Cycle: 10/3600
Water: 0/5
Water level mesurement
Water level OK
Cycle: 20/3600
Water: 0/5
Water level mesurement
Water level OK
Cycle: 30/3600
Water: 0/5
Water level mesurement
!Low water level!
Enabling pump for 5 sec
Pump enabled
Pump disabled
Total pump time in cycle: 5 sec
Cycle: 45/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 55/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 65/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 75/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 85/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 95/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 105/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 115/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 125/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 135/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 145/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 155/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 165/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 175/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 185/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 195/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 205/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 215/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 225/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 235/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 245/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 255/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 265/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 275/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 285/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 295/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 305/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 315/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 325/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 335/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 345/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 355/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 365/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 375/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 385/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 395/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 405/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 415/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 425/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 435/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 445/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 455/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 465/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 475/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 485/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 495/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 505/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 515/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 525/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 535/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 545/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 555/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 565/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 575/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 585/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 595/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 605/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 615/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 625/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 635/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 645/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 655/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 665/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 675/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 685/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 695/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 705/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 715/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 725/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 735/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 745/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 755/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 765/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 775/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 785/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 795/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 805/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 815/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 825/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 835/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 845/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 855/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 865/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 875/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 885/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 895/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 905/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 915/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 925/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 935/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 945/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 955/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 965/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 975/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 985/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 995/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1005/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1015/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1025/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1035/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1045/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1055/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1065/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1075/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1085/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1095/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1105/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1115/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1125/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1135/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1145/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1155/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1165/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1175/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1185/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1195/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1205/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1215/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1225/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1235/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1245/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1255/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1265/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1275/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1285/3600
Water: 5/5
Water level mesurement
Water level OK
Cycle: 1295/3600
Water: 5/5
Water level mesurement
Water level OK

Depuis l’album :

JDC1

  • 41 images
  • 0 commentaire
  • 10 commentaires sur l’image


Commentaires recommandés

Il n’y a aucun commentaire à afficher.