Last active
January 2, 2016 07:28
-
-
Save AtumRa/8269824 to your computer and use it in GitHub Desktop.
Differential Temperature Controller Prototype Program
http://www.youtube.com/watch?v=nsEZZS9QIao&feature=share&list=PLhtrCwA-6NNFC9vuZjVfwX6TNmPAWK0-e&index=1
http://www.youtube.com/watch?v=tPTX5_Q2qyE&feature=share&list=PLhtrCwA-6NNFC9vuZjVfwX6TNmPAWK0-e
http://www.oomlout.com/oom.php/products/ardx/circ-10
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 characters
This is code I modified for an lm34 that uses Fahrenheit instead of Celsius. Get the original code from oomlout with the link below. | |
/* --------------------------------------------------------- | |
* | Arduino Experimentation Kit Example Code | | |
* | CIRC-10 .: Temperature :. (TMP36 Temperature Sensor) | | |
* --------------------------------------------------------- | |
* | |
* A simple program to output the current temperature to the IDE's debug window | |
* | |
* For more details on this circuit: http://www.oomlout.com/oom.php/products/ardx/circ-10 */ | |
//TMP36 Pin Variables | |
int tempPin0 = 0; //the analog pin the TMP36's Vout (sense) pin is connected to | |
//the resolution is 10 mV / degree centigrade | |
//(500 mV offset) to make negative temperatures an option | |
int tempPin1 = 1; | |
int led = 13; | |
/* | |
* setup() - this function runs once when you turn your Arduino on | |
* We initialize the serial connection with the computer | |
*/ | |
void setup() | |
{ | |
Serial.begin(9600); //Start the serial connection with the computer | |
//to view the result open the serial monitor | |
//last button beneath the file bar (looks like a box with an antenae) | |
// initialize the digital pin as an output. | |
pinMode(led, OUTPUT); | |
} | |
void loop() // run over and over again | |
{ | |
float temp0 = getVoltage(tempPin0); //getting the voltage reading from the temperature sensor | |
temp0 = temp0 * 100; //the lm34 is already scaled to Fahrenheit | |
float temp1 = getVoltage(tempPin1); //getting the voltage reading from the temperature sensor | |
temp1 = temp1 * 100; //the lm34 is already scaled to Fahrenheit | |
Serial.print(temp0); //printing the result temp0 | |
// delay(1000); //waiting 1 second | |
Serial.print(" - "); | |
Serial.println(temp1); //printing the result temp1 | |
delay(1000); //waiting 1 second | |
if (temp1-temp0>10) | |
{ | |
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | |
} | |
else | |
{ | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
} | |
} | |
/* | |
* getVoltage() - returns the voltage on the analog input defined by | |
* pin | |
*/ | |
float getVoltage(int pin){ | |
return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range | |
// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment