Created
September 21, 2013 09:45
-
-
Save jakewins/6648977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int fanPin = 5; // The arduino connector that controls the motor relay | |
const int tempSensorPin = 1; // The arduino connector that is connected to our thermistor | |
const short targetTemperature = 15760; // 15760 from thermistor = 107C, or 224F | |
short currentTemperature; | |
void setup() { | |
// This sets the arduino up to talk to my laptop, to let it send temperature readings | |
Serial.begin(9600); | |
} | |
void loop() { | |
// Get the temperature from the thermistor | |
currentTemperature = (1023 * 16 - analogRead(tempSensorPin)); | |
// Send temp reading to my laptop | |
Serial.println(currentTemperature); | |
if(currentTemperature < targetTemperature) | |
{ | |
analogWrite(fanPin, 255); // Turn fan on | |
} | |
else | |
{ | |
analogWrite(fanPin, 0); // Turn fan off | |
} | |
// Wait for 2000 milliseconds, 2 seconds | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment