Hi,
I am working on a project that involves two small pumps turning on when a person breathes in. The person will be wearing a strap around their chest with a resistance cord in it. What I am trying to do is calibrate the resistance of the cord so that when an individual puts it on, the arduino will calibrate and therefore be able to tell which resistance to count as a breath in, which will then turn on my pumps. I am wondering if anyone has advice/experience coding such a thing? I have the code currently set so that I have to manually set the threshold to register as a breath in. I have attached part of my code if needed.
RespSignal = getResp(respPin); // Get resistor value
RespSignalAvg = resp_smooth.smooth(RespSignal); // Low pass filter output
//Serial.println(RespSignalAvg);
// ### Use Sensor Data ###
if (RespSignalAvg >= RespThreshold) PressureSetpoint = 50;
else PressureSetpoint = 0;
pwmVal_255 = pid2.getCmd(PressureSetpoint, Pressure); // Update PID output
if (pwmVal_255 > 0) pwmWrite(AIN1, AIN2, PWMA, pwmVal_255, 1); // Check direction, and write pwm
else if(pwmVal_255 <0 ) pwmWrite(AIN1, AIN2, PWMA, 0, -1); // Check direction, adjust speed and write pwm
Thank you!