// C++ code
//
void setup()
{
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(2,OUTPUT);// Relay PUMPS START/STOP =HIGH
pinMode(3,OUTPUT);// Relay DRY RUN /STOP=HIGH
pinMode(4,OUTPUT);//PRIMING VALVE
pinMode(5,OUTPUT);//PRESSURE RELIEF VALVE
pinMode(6,OUTPUT);//WATER LEVEL RELAY BACK
pinMode(A0,INPUT);//PRESSURE SENSOR IN (0-5V)
pinMode(A1,INPUT);//WATER FLOAT LEVEL INPUT
pinMode(A2,INPUT);//PUMPS STATUT ON OR OFF
}
void loop()
{
int WaterLevel=analogRead(A1);
if (WaterLevel<500 )//if water level is LOW Do
{
digitalWrite(6,HIGH);//return information to gtb relay back
digitalWrite(2,HIGH);//stop the pumps
tone (7,200,1000);
delay (1000);
tone (7,800,500);
Serial.println(" attention niveau d'eau tres bas");
delay(1000);
}
else {
digitalWrite(6,LOW);//return information to gtb relay back
digitalWrite(2,LOW);//stop the pumps
}
int sensorValue = analogRead(A0);// read the Presure sensor value input on analog pin 0:
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float V = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(V);
if (V==0){
Serial.println("attention capteur non connécté");
tone(7,400,1000);
digitalWrite(2,HIGH);//etindre la pompe
tone(7,200,1000);
delay(1000);
}
else
if (V>3.6){
Serial.println("Présence d'aire");
tone(7,400,1000);
digitalWrite(2,HIGH);//etindre la pompe
tone(7,200,1000);
delay(1000);
}
}