im trying to determine how much time has elapsed for a few lines of code:
//Read Flow Meter
countA=0;
cTime=millis();
for(int xCount=0; xCount<10001; xCount++){
int signalA = digitalRead(rpm_rd3); //detects tachometer signal, flow pin goes high every time the magnet spins past the sensor. NOTE: must be int.
if(signalA==1){
countA++;
}
}
pTime=millis();
FLOWCALC = countA/((pTime-cTime)/1000)*60;
but cTime and pTime are returning the same time.
this is a portion of code. i know the values are the same as i have them reading out to a 20x4 LCD.
i know i could use interrupts for this but i am using a Arduino UNO IDE 1.0.3 and pins 2 and 3 are being used for capturing RPMs from a pump and a fan using interrupts 0 and 1.
original code idea from
http://davebmiller.wordpress.com/2011/01/18/arduino-flowmeter/