I'm trying to do this:
Have the Red LED (D12) turn on when the temperature is 25C and the Blue LED (D13)
when the temperature is below 25C
Have the Green LED on the RGB (D9) turn on when the humidity is below 50% and Blue
LED on the RGB (D11) when it’s above 50%
And after two grugling days, I've gotten to here:
#include "DHT.h"
int DHT11Pin = 4; //The DHT11 sensor is connected to pin 4 of the Arduino.
int waitTime = 5000; //The amount of time to wait between sensor reads.
DHT dht(DHT11Pin, DHT11);//Initialize the sensor.
int RGBGreenPin = 10; //The green RGB LED is connected pin 10 of the Arduino.
int RGBBluePin = 11; //The blue RGB LED is connected pin 11 of the Arduino.
int LEDRedPin = 12; // The red LED is connected.
int LEDBluePin = 13; // The blue LED is connected.
void setup(){
// Setup serial monitor
Serial.begin(9600);Serial.println(); //Break for the next line in Serial Monitor
Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)"); //% of Humidity in the air, C and F Temperature values
dht.begin(); //Start the sensor.
pinMode(RGBGreenPin, OUTPUT); //Setup green RGB LED pin as an output pin.
pinMode(RGBBluePin, OUTPUT); //Setup blue RGB LED pin as an output pin.
pinMode (LEDRedPin, OUTPUT); //Stepup red LED as an output pin.
pinMode (LEDBluePin, OUTPUT); //Setup blue LED as an output pin.
}
void loop()
{
delay(waitTime);
float humidity = dht.readHumidity(); //Read the humidity value from the sensor.
float temp = dht.readTemperature(); //Read the temperature (c) value from the sensor.
float fahrenheit = dht.readTemperature(true); //Read the temperature (f) value from the sensor.
float heatIndexF = dht.computeHeatIndex(fahrenheit, humidity); //Calculate the heat index (f).
float heatIndexC = dht.computeHeatIndex(temp, humidity, false); //Calculate the heat index (c).
Serial.print("Humidity (%): ");
Serial.println(humidity ); //Display the humidity precentage.
Serial.print("Temperature(c): ");
Serial.println(temp); //Display the temperature in celsius.
Serial.print("Heat index (c): ");
Serial.println(heatIndexC); //Display the heat index in celsius.
Serial.print("Temperature(f): ");
Serial.println(fahrenheit); //Display the temperature in fahrenheit.
Serial.print("Heat index (f): ");
Serial.println(heatIndexF); //Display the heat index in fahrenheit.
Serial.println(temp);
if (digitalRead==(temp) > 24 && temp < 25)
{
analogWrite(12, HIGH);
analogWrite(13, LOW);
analogWrite(10, LOW);
analogWrite (11, LOW);
delay(1000);
}
//Changes colour to blue under 24C
if (digitalRead==(temp) > 24)
{
analogWrite(12, LOW);
analogWrite(13, HIGH);
analogWrite(10, LOW);
analogWrite(11, LOW);
delay(1000);
}
Serial.println(humidity);
if (digitalRead==(humidity) > 50%)
{
analogWrite(12, LOW);
analogWrite(13, LOW);
analogWrite(10, HIGH);
analogWrite(11, LOW);
delay(1000);
}
else
analogWrite(12, LOW);
analogWrite(13, HIGH);
analogWrite(10, LOW);
analogWrite(11, LOW);
delay(1000);
}
I'm sure this is a really dumb error, but I'm too new at this to figure it out Any thoughts?