Open your Proteus ISIS schematic capture and add the following components to your workspace using the Pick Device ( P ) window: (Requires the Arduino Proteus Library)
In Proteus, double-click the Arduino Uno component. Paste the copied path into the field, then click OK . Running and Troubleshooting the Simulation yfs201 proteus library
const int sensorPin = 2; // YF-S201 signal connected to Interrupt 0 volatile uint16_t pulseCount = 0; float flowRate = 0.0; unsigned int flowMilliLitres = 0; unsigned long totalMilliLitres = 0; unsigned long oldTime = 0; void pulseCounter() pulseCount++; // Increment pulse count on every interrupt trigger void setup() Serial.begin(9600); pinMode(sensorPin, INPUT_PULLUP); // Trigger the interrupt on a FALLING edge attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING); oldTime = millis(); void loop() // Execute calculations exactly once per second (1000 milliseconds) if ((millis() - oldTime) > 1000) detachInterrupt(digitalPinToInterrupt(sensorPin)); // Pause interrupt to prevent math calculation errors // Formula: Frequency (pulses/sec) / 7.5 = flow rate in L/min flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / 7.5; oldTime = millis(); // Calculate volume passing through during this single window flowMilliLitres = (flowRate / 60) * 1000; totalMilliLitres += flowMilliLitres; // Output results to Proteus Virtual Terminal Serial.print("Flow rate: "); Serial.print(flowRate, 2); Serial.print(" L/min"); Serial.print("\t Total Liquid: "); Serial.print(totalMilliLitres); Serial.println(" mL"); pulseCount = 0; // Reset counter for the next window attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING); // Re-engage interrupt Use code with caution. Compiling and Loading the Binary Open your Proteus ISIS schematic capture and add
If the library doesn’t appear, check the file naming and ensure you have the correct version of Proteus (8.x or newer). Compiling and Loading the Binary If the library
The YF-S201 is a popular, low-cost water flow sensor that uses a magnetic hall-effect sensor to measure fluid velocity. For embedded systems developers and students, testing this hardware in a virtual environment before prototyping saves time and prevents component damage.
How to Add Arduino UNO Library to Proteus | Step-by-Step Guide