Hi to all! I am trying to make a car engine oil pressure gauge. I read analog pressure and I have installed a buzzer to make an alarm. My problem is that I want the alarm to ring if pressure goes lower than 0.5 bar of pressure and it should not ring before and starts. So I have to make a loop that if it is lower than 0.5bar ring but only if pressure have been for on time over 0.5 bar. Any idea ?
my code for now
void loop() {
// read the value at analog input
value = analogRead(1);
vout = (value * 5.0) / 1024.0;
if (vout<0.5) {
digitalWrite(4, HIGH); // turn the buzzer on
}
else {
digitalWrite(4, LOW);
}
Many thanks to all!!!