Hello. I have a problem and I need a sample code structure for this issue. We have a circuit that measures insulation resistance. This value is sampled every 500 ms. Our circuit sometimes gives a low value momentarily. In this case, the alarm is activated immediately and the alarm works for a very short time until a new value arrives. We do not want this short-term triggering.
For example, we want to take and process 10 sensor values in 5 seconds. If the sensor values are lower than 100 tree times in a row, then we want the alarm to be triggered.
How can we create this code structure? Thanks in advance for your support.
tizo1Zaman = millis();
if(tizo1Zaman-tizo2Zaman > 500)
{
if(izolasyon_direnci<100)
{
digitalWrite(flasor, HIGH);
}
else
{
digitalWrite(flasor, LOW);
}
tizo1Zaman=tizo2Zaman;