LCD and DHT skeetch displaying junk

Hello Every body.

I´m new at the arduino world and I´m amazed with this controllers.

I copied a simple lcd sketch and worked well on my display.

#include <LiquidCrystal.h>
LiquidCrystal lcd(1,2,4,5,6,7);

void setup()
{
lcd.begin(16,2);
}

void loop()
{
lcd.setCursor(0,0);
lcd.print(" HOLA INTEGRA");
delay (1000);
lcd.setCursor(0,1);
lcd.write(" REGRESE!!!");
delay(1000);
lcd.clear();
delay(1000);

}

then I copied another sketch related to the DHT sensor and also worked fine displaying the data to the serial interface of my PC.

// DHT Temperature & Humidity Sensor
// Unified Sensor Library Example
// Written by Tony DiCola for Adafruit Industries
// Released under an MIT license.

// Depends on the following Arduino libraries:
// - Adafruit Unified Sensor Library: GitHub - adafruit/Adafruit_Sensor: Common sensor library
// - DHT Sensor Library: GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 8 // Pin which is connected to the DHT sensor.

// Uncomment the type of sensor in use:
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// See guide for details on sensor wiring and usage:
// Overview | DHT11, DHT22 and AM2302 Sensors | Adafruit Learning System

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup()
{

Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println(“DHTxx Unified Sensor Example”);
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println(“Temperature”);
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(” *C”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(” *C”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(” *C”);
Serial.println(”------------------------------------”);
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println(”------------------------------------”);
Serial.println(“Humidity”);
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(”%”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(”%”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(”%”);
Serial.println(”------------------------------------”);
// Set delay between sensor readings based on sensor details.

}

void loop()
{
// Delay between measurements.
delay(delayMS);
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(“Error reading temperature!”);
}
else {
Serial.print(“Temperature: “);
Serial.print(event.temperature);
Serial.println(” *C”);
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(“Error reading humidity!”);
}
else {
Serial.print(“Humidity: “);
Serial.print(event.relative_humidity);
Serial.println(”%”);
}

}

the I decided to add this lines to the DHT skeetch and it only shows junk on the lcd display.

#include <LiquidCrystal.h>
LiquidCrystal lcd(1,2,4,5,6,7);

lcd.begin(16,2);

lcd.setCursor(0,0);
lcd.print(" HOLA INTEGRA");
delay (1000);
lcd.setCursor(0,1);
lcd.write(" REGRESE!!!");
delay(1000);
lcd.clear();
delay(1000);

the final sketch is as follows:

// DHT Temperature & Humidity Sensor
// Unified Sensor Library Example
// Written by Tony DiCola for Adafruit Industries
// Released under an MIT license.

// Depends on the following Arduino libraries:
// - Adafruit Unified Sensor Library: GitHub - adafruit/Adafruit_Sensor: Common sensor library
// - DHT Sensor Library: GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#include <LiquidCrystal.h> //<---------------------------------------------inserted line
LiquidCrystal lcd(1,2,4,5,6,7); //<---------------------------------------------inserted line

#define DHTPIN 8 // Pin which is connected to the DHT sensor.

// Uncomment the type of sensor in use:
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// See guide for details on sensor wiring and usage:
// Overview | DHT11, DHT22 and AM2302 Sensors | Adafruit Learning System

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup()
{
lcd.begin(16,2); //<---------------------------------------------inserted line

Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println(“DHTxx Unified Sensor Example”);
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println(“Temperature”);
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(” *C”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(” *C”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(” *C”);
Serial.println(”------------------------------------”);
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println(”------------------------------------”);
Serial.println(“Humidity”);
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(”%”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(”%”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(”%”);
Serial.println(”------------------------------------”);
// Set delay between sensor readings based on sensor details.

}

void loop()
{
// Delay between measurements.
delay(delayMS);
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(“Error reading temperature!”);
}
else {
Serial.print(“Temperature: “);
Serial.print(event.temperature);
Serial.println(” *C”);
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(“Error reading humidity!”);
}
else {
Serial.print(“Humidity: “);
Serial.print(event.relative_humidity);
Serial.println(”%”);
}
lcd.setCursor(0,0); //<---------------------------------------------inserted line
lcd.print(" HOLA INTEGRA"); //<---------------------------------------------inserted line
delay (1000); //<---------------------------------------------inserted line
lcd.setCursor(0,1); //<---------------------------------------------inserted line
lcd.write(" REGRESE!!!"); //<---------------------------------------------inserted line
delay(1000); //<---------------------------------------------inserted line
lcd.clear(); //<---------------------------------------------inserted line
delay(1000); //<---------------------------------------------inserted line
}

the serial port still recives the data correctly but the lcd shows junk.

does any one knows why this is not working?

thank you in advance!

First off, always format your code with CTRL T

Secondly, always use code tags.
Please use code tags. Use the </> icon in the posting menu.

[code ]Paste sketch here. [/code ]

It is note recommended to use pin 1, it is the TX pin.
Use a different pin.

.

I changed the pin and it worked.

thank you larryD for the format recommendation and your support.