Difference between revisions of "Temperature Sensor."
(6 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
and to keep the incubator at a certain threshold temperature. <br> | and to keep the incubator at a certain threshold temperature. <br> | ||
+ | [[File:i.jpg]] | ||
<br> | <br> | ||
Parts list: | Parts list: | ||
Line 18: | Line 19: | ||
<br><br> | <br><br> | ||
− | <B> Arduino Code LM 35 Temperature Sensor </B> | + | <B> Arduino Code LM 35 Temperature Sensor </B> <br><br><br> |
− | float tempC; // create variable to store the temperature in. | + | float tempC; // create variable to store the temperature in. <br> |
− | int tempPin = 0; // Attach vout to analog pin 0. | + | int tempPin = 0; // Attach vout to analog pin 0. <br> |
− | int led = 13; // attach led to pin 13. | + | int led = 13; // attach led to pin 13. <br> |
− | int fan1 = 3; // attach base of transistor to digital pin 3. | + | int fan1 = 3; // attach base of transistor to digital pin 3. <br> |
− | int pos = 0; // create variable to store the position of the servo motor. | + | int pos = 0; // create variable to store the position of the servo motor. <br> |
+ | void setup() // Will execute once at the start of the code. <br> | ||
+ | { <br> | ||
+ | Serial.begin(9600); // opens serial port, sets data rate to 9600 bps <br> | ||
+ | pinMode (led, OUTPUT); // sets the led pin 13 up as an output. <br> | ||
+ | pinMode (fan1, OUTPUT); // sets the fan1 pin 3 up as an output. <br> | ||
+ | <br> | ||
+ | }<br> | ||
− | void | + | void loop() // code here will continue to replay nutil powered off. <br> |
− | { | + | { <br> |
− | + | tempC = analogRead(tempPin); // read the analog value from the lm35 sensor. <br> | |
− | + | tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade. <br> | |
− | + | Serial.print((byte)tempC); // send the data to the computer. <br> <br> | |
− | |||
− | |||
− | + | if (tempC > 38) // creates bool expression for analyzation. if it evaluates to true, <br> | |
− | + | { // the body of the if statement will execute. <br> | |
− | + | <br> | |
− | + | digitalWrite (led, HIGH); // turns on led.<br> | |
− | + | digitalWrite (fan1, HIGH); // turns on fan1. <br> | |
− | + | <br> | |
− | if (tempC > 38) // creates bool expression for analyzation. if it evaluates to true, | + | }<br> |
− | { // the body of the if statement will execute. | + | else // if the if equation evaluates to false the else statement will execute.<br> |
− | + | { <br> | |
− | digitalWrite (led, HIGH); // turns on led. | ||
− | digitalWrite (fan1, HIGH); // turns on fan1. | ||
− | |||
− | } | ||
− | else // if the if equation evaluates to false the else statement will execute. | ||
− | { | ||
− | |||
− | |||
− | |||
− | } | + | digitalWrite (led, LOW); // turns off led. <br> |
− | delay(3000); // wait 3 seconds before redoing the loop. | + | digitalWrite (fan1, LOW); // turns off fan1. <br> |
− | } | + | <br> |
+ | }<br> | ||
+ | delay(3000); // wait 3 seconds before redoing the loop. <br> | ||
+ | }<br> | ||
</p> | </p> |
Latest revision as of 07:58, 27 April 2013
Reauben Samson has made an incubator and we need to check if it is working. We used a digital thermometer,
it gives us different readings after every 15 minutes and we concluded it does not work so now we are
building a temperature sensor using the Arduino Uno board and LM35 temperature sensor. The main aim is to keep
a constant temperature using a light bulb as our heat source. We will be using a CPU fan to cool down the light bulb
and to keep the incubator at a certain threshold temperature.
Parts list:
CPU fan
LED
Light bulb (230 VOLT, 75 WATTS)
LM 35 (temperature sensor)
Diode (2N3904 - E25)
Relay (JQC-3F 6 VOLT)
Wire
Arduino Uno
Arduino Code LM 35 Temperature Sensor
float tempC; // create variable to store the temperature in.
int tempPin = 0; // Attach vout to analog pin 0.
int led = 13; // attach led to pin 13.
int fan1 = 3; // attach base of transistor to digital pin 3.
int pos = 0; // create variable to store the position of the servo motor.
void setup() // Will execute once at the start of the code.
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode (led, OUTPUT); // sets the led pin 13 up as an output.
pinMode (fan1, OUTPUT); // sets the fan1 pin 3 up as an output.
}
void loop() // code here will continue to replay nutil powered off.
{
tempC = analogRead(tempPin); // read the analog value from the lm35 sensor.
tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.
Serial.print((byte)tempC); // send the data to the computer.
if (tempC > 38) // creates bool expression for analyzation. if it evaluates to true,
{ // the body of the if statement will execute.
digitalWrite (led, HIGH); // turns on led.
digitalWrite (fan1, HIGH); // turns on fan1.
}
else // if the if equation evaluates to false the else statement will execute.
{
digitalWrite (led, LOW); // turns off led.
digitalWrite (fan1, LOW); // turns off fan1.
}
delay(3000); // wait 3 seconds before redoing the loop.
}