I am new with arduino, i am trying to connect DHT22 to control couple of LEDs, and servo motor, i know how to connect dht sensor, but can someone show me how to turn of and on LEDs with moisture and temperature. i have conected everything,when
temperature is low i need to turn 1 LED, if it gets over t=25 servo needs too turn 45 degrees, and if moisture fals under 45 precentage to turn on LED.
X-mas gift
code is not tested and might need minor tweaks
[code = partial]
#define SERVOPIN 9
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(115200);
}
void loop()
{
int temp = getTemperature(); // you know how this is done
int hum = getHumidity();
Serial.print(temp);
Serial.print("\t");
Serial.println(hum);
if ( (temp < 10) || (hum > 45) ) digitalWrite(13, HIGH);
else digitalWrite(13, LOW);
if (temp > 25) analogWrite(SERVOPIN, 45); // depends on servo
if (temp < 25) analogWrite(SERVOPIN, 0);
delay(2000); // DHT may not be sampled more often
}