So I'm using an Arduino Uno, a 162LCDBLACK LCD screen, a YF201-C water flow sensor and a small breadboard for a product I'm making. It's made for displaying the amount of water that goes through the water flow sensor and I want to add 3 lights that turn on/off after an amount of water used, but when programming I came across the 'pulseCounter was not declared in this scope' error message. Just when verifying the code so no electronics that have anything to do with this. See code below:
**if (totalLitres >= 60) { // if the total amount of L used is more than 60L, than red LED gives light**
** digitalWrite(ledPINR, HIGH);**
** }**
** else if (totalLitres >= 30 && <= 60) { // if the total amount of L used is more than 30L and less than 60L, than the orange LED gives light**
** digitalWrite(ledPINO, HIGH);**
** digitalWrite(ledPING, LOW);**
** }**
** else ( // if the total amount of L used is below than 30L, than the green LED gives light**
** digitalWrite(ledPINO, LOW);**
** digitalWrite(ledPING, HIGH);**
** }**
// Reset the pulse counter so we can start incrementing again
pulseCount = 0;
// Enable the interrupt again now that we've finished sending output
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
Serial.print(flowRate, DEC); // Print litres/hour
Serial.println(" L/minute");
Serial.println(totalMilliLitres);
Serial.println(totalLitres);
}
}
/*
I.S.R.
*/
void pulseCounter()
{
// Increment the pulse counter
pulseCount++;
}
So it's about the bold part of the code, if that code is there I get the error and when I remove it, I don't get the error. Does anyone know why this is happening?