Arduino Thermostat with TC74 sensor

 by gummygoodness
Featured

Step 5: Setting Threshold Fan/Heater Values

IMG_1618.JPG
Now is when the potentiometers come into play.  Connect the potentiometers, with the two ends on 5V and ground and the middle going to an analog input.  Do this for the other appliance's potentiometer as well.

In order to read out what the potentiometer tells the Arduino, initialize the variables and code the following...

fanDigit = analogRead(fanAnalog)/4;
heaterDigit = analogRead(heaterAnalog)/4;

This will give the Arduino a number from 0-255 depending on where the potentiometer is twisted.

This can be used to provide a threshold, with an example of code for the application of a threshold below.

fanThreshold = 20 + fanDigit*10/255;
heaterThreshold = 10 + heaterDigit*10/255;

<more code>
//inside void loop()
if(temperature>fanThreshold) {
        digitalWrite(13, HIGH);
      }
       else {
         digitalWrite(13, LOW);
       }
       if(temperature<heaterThreshold) {
         digitalWrite(4, HIGH);
       }
       else {
         digitalWrite(4, LOW);
       }
 
Remove these adsRemove these ads by Signing Up
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!