Hi! i’m new at this, and i have problems about timing.
float sensorValue;
float Volume = 0;
float Vt=0;
int k=0;
float Tension;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(A0);
if ((sensorValue > (519))||(sensorValue <(497))){ // f signal != the capteur is at rest
Calcul_Volume();
}
else{
if (Volume != 0.00){
Vt=Volume;
Serial.println("vT:");
Serial.println(Vt); // final volume from my integral calculation
}
Volume=0;
k=0;
}
}
void Calcul_Volume(){
while (sensorValue > (519)){ //
sensorValue = analogRead(A0); // Read A0
sensorValue = sensorValue -508; // make "0.00" (508 is the capteur value at rest)
Tension = sensorValue * (5.0/1024.0); // switch to Volts
Volume= ((Tension)*0.01) + Volume; // integral
k++;
}
}
i wish my arduino could execute “void Calcul_Volume” every 10ms. Otherwise, my Volume calculation is false.
I’m doing this for a device for respiration exercices.
Could u help me for implanting a timer to do that?
(my english is so bad, sorry)
thank you anyway