Hello Pro,
I am having a crazy issue with the LCD backlight. I modified a DHT22 I2C LCD sketch and have gotten the sketch to work with one exception.. THE LCD BACKLIGHT! I have tried placing it in multiple locations, the latest is highlighted in red... Can anyone help me. I need to see this through a plastic bin I am testing a dehumidifier in... it is terrible without backlight but will not stop me..
If you can point out what in the library I am defining incorrectly it would help grandly .. Thanks in advance.
/* How to use the DHT-22 sensor with Arduino uno
Temperature and humidity sensor
More info: Temperature and Humidity - DHT22 and Arduino - Ardumotive Arduino Greek Playground
Dev: Michalis Vasilakis // Date: 1/7/2015 // www.ardumotive.com
*/
//Libraries
#include <DHT.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//ALWAYS USE THIS WITH LCD I2C and Addres 0x3F
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
lcd.begin(16,2);
}
void loop()
{
delay(2000);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
lcd.backlight(); // turn on backlight
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print(" ");
lcd.print((char)223);
lcd.print("C");
lcd.setCursor(0,1);
lcd.print("Hum: ");
lcd.print(hum);
lcd.print(" %");
delay(2000); //Delay 2 sec.
}