I was going through the concept of Interrupts in Arduino and found myself stuck at a point. I just wrote a simple Arduino code to count the number of pulses generated in one second by the Water Flow Sensor YF-S401 sensor.
I am having couple of problems with the output of the code. The problems are as follows:
In the above code, I have just written the code to count the number of pulses generated / no of revolutions incurred by the rotor of the flow sensor. In this case it was 12. I have used Serial.println() to print out two variables ie flowRate and count. But only the first print statement is being executed. Why the second one is not there? Output for the above code is:
Also I saw that whenever I am trying to print a variable (be it string, int or double), in the output only two places are visible. For eaxmple see this screenshot:
Should digitalPinToInterrupt(0) be the first parameter, instead of just 0?
Also, do you really need to use pin 0? I try to avoid using 0 & 1 unless the world is ending.
Also, you have flowPin = 2, what is this pin for?