Making a fridge like program.
hello users.
i making "fridge" program, need arduino board start cooling when it's on 25 degrees celcius, , stop cooling when it's below 23 degrees celcius.
this using dht library
this i've far.
this won't inbetween 24-25 period, it's doesn't cooldown, how could fix this?
i making "fridge" program, need arduino board start cooling when it's on 25 degrees celcius, , stop cooling when it's below 23 degrees celcius.
this using dht library
this i've far.
code: [select]
// example testing sketch various dht humidity/temperature sensors
// written ladyada, public domain
#include "dht.h"
#define dhtpin 2 // pin we're connected to
// uncomment whatever type you're using!
//#define dhttype dht11 // dht 11
#define dhttype dht22 // dht 22 (am2302)
//#define dhttype dht21 // dht 21 (am2301)
// connect pin 1 (on left) of sensor +5v
// connect pin 2 of sensor whatever dhtpin is
// connect pin 4 (on right) of sensor ground
// connect 10k resistor pin 2 (data) pin 1 (power) of sensor
dht dht(dhtpin, dhttype);
int cooler = 12;
void setup() {
serial.begin(9600);
serial.println("dhtxx test!");
pinmode(cooler, output);
dht.begin();
}
void loop() {
// reading temperature or humidity takes 250 milliseconds!
// sensor readings may 2 seconds 'old' (its slow sensor)
float h = dht.readhumidity();
float t = dht.readtemperature();
// check if returns valid, if nan (not number) went wrong!
if (isnan(t) || isnan(h)) {
serial.println("failed read dht");
} else {
serial.print("humidity: ");
serial.print(h);
serial.print(" %\t");
serial.print("temperature: ");
serial.print(t);
serial.println(" *c");
if (t <= 24) {
digitalwrite(cooler, low);
serial.print ("stopped cooling");
}
else (t >= 25)
{
digitalwrite(cooler, high);
serial.print(" start cooling");
}
}
}
this won't inbetween 24-25 period, it's doesn't cooldown, how could fix this?
remove else statement , replace if statement.
Arduino Forum > Using Arduino > Programming Questions > Making a fridge like program.
arduino
Comments
Post a Comment