Code for arduino run on timer help beginner thanks

This is my code and I,m trying to put in a run on timer…, when my digital write 4 comes on it will go off when its greater than 2.5v and my program continues on…but I,m trying to put in the timer if it doesn,t hit that threshold 2.5v in 5 mins it will shut my digital write 4 off and another digital write 6 off

if (analogValue < threshold2){ //less 2volts digitalWrite(4,HIGH) ; //compressor on

} if (analogValue > threshold3){ //greater than 2.5 volts digitalWrite(4,LOW) ; // compressor off

}

Please post all your code and don't forget to put it inside code tags.

const int analogPin = A1; // Analog input pin that the potentiometer is attached to

const int threshold1 = 51 ; // 0.25 Volt value
const int threshold2 = 410 ; // 2 Volt value
const int threshold3 = 512 ; // 2.5 Volt value
const int threshold4 = 615 ; // 3 Volt value
const int threshold5 = 972 ; //4.75 volt value
void setup() {
pinMode(4, OUTPUT) ; // compressor led light
pinMode(6, OUTPUT) ; // Exhaust Valve light
Serial.begin(9600); // initialize serial communications at 9600 bps:
}
void loop() {
int analogValue = analogRead(analogPin);
if
(analogValue > threshold5){ // if analog value greater than 4.75v
digitalWrite(4,LOW); // turn off compressor
digitalWrite(6,LOW); // turn off exhaust valve
delay(60000); // resets after 60 seconds
}
if
(analogValue < threshold1){ //if analog value less than 0.25v
digitalWrite(4,LOW); //turn off compressor
digitalWrite(6,LOW); //turn off exhaust valve
delay(60000) ; // reset after 60 seconds
}
if
(analogValue < threshold2){ //less 2volts
digitalWrite(4,HIGH) ; //compressor on

}
if
(analogValue > threshold3){ //greater than 2.5 volts
digitalWrite(4,LOW) ; // compressor off

}

if
(analogValue > threshold4) { //greater than 3volts
digitalWrite(6,HIGH) ; //exhaust valve on
}

if
(analogValue < threshold3) //less than 2.5volts
{
digitalWrite(6,LOW) ; //exhaust valve off
}
Serial.println(analogValue) ;
delay(1) ;
}

and don't forget to put it inside code tags.

Oopsie

❝and don't forget to put it inside code tags.

Sorry what is this i,m new to this ,what do you mean by inside code tags?

Please read the thread "How to use this forum - please read." near the top of the forum.

Code should

look like this

Use the code button. It looks like a scroll with <> on top.

…R

You have a lot of problems in here:

 if
 (analogValue > threshold5){      // if analog value greater than 4.75v
   digitalWrite(4,LOW);                // turn off compressor
   digitalWrite(6,LOW);              // turn off exhaust valve
   delay(60000);                            // resets after 60 seconds
 }
 if
 (analogValue < threshold1){   //if analog value less than 0.25v
   digitalWrite(4,LOW);             //turn off compressor
   digitalWrite(6,LOW);            //turn off compressor
   delay(60000) ;                       // reset after 10 seconds
 }

The delays are the same, 60000, but the comments say otherwise.
In the second part, you comment that you’re turning off the compressor, but you actually turn off the valve.
Did you really mean to turn everything off (LOW)?

You used const int to give meaningful variable names to the analog pin. Please do it for the output pins too, so you and other readers don’t get confused.

Is the analog input connected to a pressure sensor? How about calling your analogValue variable “pressure” to make the comparison statements read more meaningfully? How about using the auto format feature in the IDE to improve the formatting of your statement blocks?