Grove - Temperature&Humidity Sensor with 3 Leds

Hello,

I’m trying to make the temperature & humidity Sensor work with 3 leds.

One were there is a green light on = everything is fine
One for a orange light = Humidity is medium
One for a red light = Humidity is high

The problem is that the leds dont work with the humidity sensor so far.
The serial monitor gives me the right data for temperature but doesn’t seem to correspont with the leds.
Is there anything I did wrong?
This is my code so far:

#include <dht.h>

dht DHT;
#define DHT11_PIN D7

#define LedPin = D3
#define ledPin = D5
#define ledpin = D6

void setup(){
  Serial.begin(115200);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay(1000);

//Groen(D3), Geel(D5), Rood(D6)
  if (DHT.humidity<=40)
  {
  digitalWrite(D3, HIGH);
  digitalWrite(D5, LOW);
  digitalWrite(D6, LOW);
  }
  else if (DHT.humidity>44 && DHT.humidity<60)
  {
  digitalWrite(D3, LOW);
  digitalWrite(D5, HIGH);
  digitalWrite(D6, LOW);
  }
  else if (DHT.humidity>60)
  {
  digitalWrite(D3, LOW);
  digitalWrite(D5, LOW);
  digitalWrite(D6, HIGH);
  } 
  
}

moderator: added code tags

The pins are set to input by default on reset. YOU must change the pins to OUTPUT with the pinMode(pin,OUTPUT) preferably in setup(). https://www.arduino.cc/en/Tutorial/DigitalPins

#define LedPin = D3
#define ledPin = D5
#define ledpin = D6

do you think that giving the pins nearly the same name is wise? Why not redLed, greenLED and orangeLed? Seems easier to keep track of. You define names but do not use the names, why bother? And just use the numbers. The D is not needed and may not even work.

You will have to fix the pinModes, the rest is FYI.

Thanks for your fast response! This makes it a lot clearer already. I have tried to implement the instructions you gave but it still doesn’t seem to work.

#include <dht.h>

dht DHT;
#define DHT11_PIN D7

#define greenLED_PIN    3
#define orangeLED_PIN   5
#define redLED_PIN      6

void setup(){
  Serial.begin(115200);
  pinMode(greenLED_PIN,OUTPUT);
  pinMode(orangeLED_PIN,OUTPUT);
  pinMode(redLED_PIN,OUTPUT); 
}

This is what I have now, do I need to make output pinmodes for alle the LED’s in the void setup like I did or is this not how it’s supposed to be written?

Thanks in advance!

@arata

tip of the day: use CTRL-T in the IDE to auto format your code (get indentation consistent). This makes it more readable for use mere humans ;)

The LED pin defines and pinModes look right. I would change DHT11_PIN D7 to just 7.

Does the dht library use a begin() method in setup()? Look at the library examples to be sure.

Karma for using code tags.