This is the code I used in arduino. Works well.
#define temp_low_sensor 6
#define temp_high_sensor 7
#define power_relay 8
boolean set_bit;
void setup() {
pinMode(temp_low_sensor, INPUT);
pinMode(temp_high_sensor, INPUT);
pinMode(power_relay, OUTPUT);
digitalWrite(power_relay,LOW);
}
void loop() {
if(digitalRead(temp_low_sensor) == LOW && digitalRead(temp_high_sensor) == LOW){ //turning on relay if temperature is Low
digitalWrite(power_relay,HIGH);
set_bit = 1; // variable used to sense Low to high & high to Low transition
}
else if(digitalRead(temp_low_sensor) == HIGH && set_bit==1){ // Keep running the Relay ON if temperature is Low and in Low transition
digitalWrite(power_relay,HIGH);
}
else if(digitalRead(temp_high_sensor) == HIGH){ // turn the relay off, once the temperature is High
digitalWrite(power_relay,LOW);
set_bit = 0;
}
}
Needed: I want to implement this without controller as this is 2 input one output. The truth table is
Low sensor High sensor relay
0 0 1 (when temp is too low)
1 0 1 ( when temp is low)
1 1 0 (when temp is high)
1 0 0 (when temp is in range)
0 0 1 (when temp is too low)
We cant call this as truth table, as it violates the property of showing different output for same input for different times.
What I am trying to do is the Logic diagram, But I could not make it, as it has one "set_bit" variable, that I used in code.
I tried NAND gate and helpless.
Thank you for your help in advance.