const int triggerPin = 8; const int fanPin = 9; const int coilPin = 13; const int period = 50; const int temperaturePin = A3; // select the input pin for the temperature sensor int temperature = 0; // variable to store the value coming from the temperature sensor void setup() { pinMode(coilPin, OUTPUT); pinMode(fanPin, OUTPUT); pinMode(triggerPin, INPUT); Serial.begin(9600); } void loop() { // read the value from the temperature sensor: temperature = (5.0 * analogRead(temperaturePin) * 100.0) / 1024.0; Serial.print(temperature, DEC); Serial.print("\n"); int trigger = digitalRead(triggerPin); //Serial.print(digitalRead(triggerPin)); if(temperature < 80){ digitalWrite(fanPin, HIGH); if(trigger == LOW){ digitalWrite(coilPin, HIGH); delay(period); digitalWrite(coilPin, LOW); delay(period); } else{ //digitalWrite(fanPin, LOW); } } if(temperature > 30){ digitalWrite(fanPin, HIGH); } }