if (digitalRead(Plin) == LOW) // rezervor plin
{
Serial.println("Apa la maxim -- Cantitate = 1000 Litri ");
digitalWrite(Releu, HIGH); // pompa se opreste
if (digitalRead(Releu) == HIGH)// contor rezervor plin
{
Count++; // Increase count by one
Serial.print("Count: ");
Serial.println(Count);
delay(1000);
}
digitalWrite(LedVerde, HIGH); // led verde aprins
digitalWrite(LedGalben, HIGH); // led galben aprins
digitalWrite(LedRosu, HIGH); // led rosu aprins
}
else // daca rezervorul nu e plin
if (digitalRead(Plin) == HIGH)
{
digitalWrite(LedVerde, HIGH); // led verde aprins
delay(750); // timp aprins
digitalWrite(LedVerde, LOW); // led verde stins
delay(750); // timp stins
digitalWrite(LedGalben, HIGH); // led galben aprins
digitalWrite(LedRosu, HIGH); // led rosu aprins
}
else // daca scazut nivelul sub jumatate
if (digitalRead(Mijloc) == HIGH)
{
Serial.println("Apa sub jumatate= 500 Litri ");
digitalWrite(LedVerde, LOW); // led verde stins
digitalWrite(LedGalben, HIGH); // led galben aprins
delay(450); // timp aprins
digitalWrite(LedGalben, LOW); // led galben stins
delay(450); // timp stins
digitalWrite(LedRosu, HIGH); // led rosu aprins
}
else // daca nivelul e sub minim
if (digitalRead(Gol) == HIGH)
{
Serial.println("Rezervor gol");
digitalWrite(Releu, LOW); // pompa porneste
digitalWrite(LedVerde, LOW); // led verde stins
digitalWrite(LedGalben, LOW); // led galben stinss
digitalWrite(LedRosu, HIGH); // led rosu aprins
delay(250); // timp aprins
digitalWrite(LedRosu, LOW); // led rosu Stins
delay(250); // timp stins
}
If you read the state of an input pin in loop() and count when it is HIGH then the state will be checked thousands of times per second and the count may be incremented thousands of times per second
If you read the state of an input pin in loop() and count when it becomes HIGH then the state will be checked thousands of times per second but the count will only be incremented once for every time the input becomes HIGH, such as when a button is pressed, for example
The first option is generally useless as the count is meaningless. Which one do you want to implement ?