Created
September 21, 2013 09:45
-
-
Save jakewins/6648977 to your computer and use it in GitHub Desktop.
Revisions
-
jakewins created this gist
Sep 21, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 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); }