Go Down

Topic: Dimming an LED makes lcd garbled (Read 312 times) previous topic - next topic

pwatsoon

Jun 19, 2017, 09:28 am Last Edit: Jun 19, 2017, 09:51 am by pwatsoon
Hi Guys,

I am doing a project for work. Basically I am using an external 5V supply to power some 85mA LEDS through transistors. At the moment I am playing around with a dht11 sensor and trying to show temperature and humidity on an LCD screen (came with the Arduino starter kit 16x2). I've encountered a couple of issues so far.

1. When I power the board up everything works fine but as soon as I dim one LED up the screen goes garbled.

2. When I dim the LED it takes a second to register due to the delay on the temp and humidity part of the code is there any way around this?

Since posting temp and humidity both read -999 both on the lcd and the serial monitor now? I tried capacitors between +, - and a diode but have removed all now. any ideas?

pwatsoon

#include <dht.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
dht DHT;

#define DHT11_PIN 13

int led1 = 6;
int const pot1 = A0;
int brightness1 = 0;
int level1 =0;

void setup(){
  Serial.begin(9600);
  pinMode(led1, OUTPUT);

  lcd.begin(16, 2);
 
}

void loop()
{
 
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
 
  Serial.print("Temperature = ");
  Serial.println(DHT.temperature);
  Serial.print("Humidity = ");
  Serial.println(DHT.humidity);
  delay (1000);
 
  brightness1 = analogRead(pot1);
  level1 = map(brightness1 , 0, 1023, 0, 255);
  analogWrite(led1, level1);
 
}

Wawa

#2
Jun 20, 2017, 02:45 am Last Edit: Jun 20, 2017, 02:46 am by Wawa
Basically I am using an external 5V supply to power some 85mA LEDS through transistors.
Need to see a circuit diagram and a real picture of the setup.

When I dim the LED it takes a second to register due to the delay on the temp and humidity part of the code is there any way around this?
Use millis() for timing.
Explained in the "BlinkWithoutDelay" example in the IDE.
Leo..

Go Up