void pulseCounter() pulseCount++;
Serial.print("Flow Rate: "); Serial.print(flowRate); Serial.print(" L/min\t\tTotal: "); Serial.print(totalLiters); Serial.println(" L"); yf-s201 proteus library
void loop() unsigned long now = millis(); if (now - lastTime >= 1000) // Every second detachInterrupt(digitalPinToInterrupt(2)); void pulseCounter() pulseCount++; Serial
void setup() Serial.begin(9600); pinMode(2, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(2), pulseCounter, FALLING); lastTime = millis(); void pulseCounter() pulseCount++
If you have searched for "YF-S201 Proteus Library" on Google, GitHub, or Labcenter’s official forums, you have likely come up empty-handed. Out of the box, Proteus (version 8 and 9) does not include a native simulation model for flow sensors.
flowRate = (pulseCount / PULSES_PER_LITER) * 60.0; // L/min totalLiters += flowRate / 60.0; // Add volume for 1 second