Hello
Try this sketch. You may make some edits to this sketch wrt to your reqiuerements.
// BLOCK COMMENT
// https://forum.arduino.cc/t/three-inputs-to-control-single-output-led/901093
#define ProjectName "Three Inputs to control single output(led)"
// CONSTANT DEFINITION
// you may need to change these constants to your hardware
constexpr byte Temp_[] {A3, A4, A5}; // connection to LowPot, HighPot, InSensor
constexpr byte Output_[] {2}; // connection to indicator
constexpr unsigned long measurementInterval {1000};
// VARIABLE DECLARATION
enum {One};
enum {LowPot, HighPot, InSensor};
struct TEMP {
byte pin;
int min_;
int max_;
} temp [] {
{Temp_[LowPot], 0, 511},
{Temp_[HighPot], 512, 1023},
{Temp_[InSensor], 0, 1013},
};
struct TIMER {
unsigned long duration;
unsigned long stamp;
bool control_;
};
TIMER readTemp {measurementInterval, 0, true};
struct LED {
byte pin;
};
LED led {Output_[One]};
// FUNCTIONS
void setup() {
Serial.begin(9600);
Serial.println(F("."));
Serial.println(F("File : ")), Serial.println(__FILE__);
Serial.println(F("Date : ")), Serial.println(__DATE__);
Serial.println(F("Project: ")), Serial.println(ProjectName);
pinMode (LED_BUILTIN, OUTPUT);
for (auto Output : Output_) pinMode(Output, OUTPUT);
// check outputs
for (auto Output : Output_) digitalWrite(Output, HIGH);
delay(1000);
for (auto Output : Output_) digitalWrite(Output, LOW);
}
void loop () {
unsigned long currentTime = millis();
digitalWrite(LED_BUILTIN, (currentTime / 500) % 2);
if (currentTime - readTemp.stamp >= readTemp.duration && readTemp.control_) {
readTemp.stamp = currentTime;
int tempMin = map(analogRead(temp[LowPot].pin), temp[InSensor].min_, temp[InSensor].max_, temp[LowPot].min_, temp[LowPot].max_);
int tempMax = map(analogRead(temp[HighPot].pin), temp[InSensor].min_, temp[InSensor].max_, temp[HighPot].min_, temp[HighPot].max_);
int tempInSensor = map(analogRead(temp[InSensor].pin), temp[InSensor].min_, temp[InSensor].max_, temp[InSensor].min_, temp[InSensor].max_);
Serial.print("\nread temp tempInSensor: "); Serial.println(tempInSensor);
if (tempInSensor < tempMin) {
digitalWrite(led.pin, HIGH);
Serial.print("read tempMin: "); Serial.println(tempInSensor);
}
if (tempInSensor > tempMax) {
digitalWrite(led.pin, LOW);
Serial.print("read tempmax: "); Serial.println(tempMax);
}
}
}
Have a nice day and enjoy coding.