Problemas con LCD 20x04 con I2C

Hola! estoy teniendo un problema con quitar los parámetros en una pantalla LCD 20x04 con modulo I2C, ya tengo el código pero no muestra en pantalla, este es el código si alguien puede ayudarme rápido porfavor!

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

//Crear el objeto lcd  dirección  0x3F y 16 columnas x 2 filas
LiquidCrystal_I2C lcd(0x27,20,4);  //

 
  // variales temporales
unsigned long marca1, marca2;

// Define Trig and Echo pin:
#define trigPin 2
#define echoPin 3

// Define variables:
long duration;
int distance;
float Po;

// Constantes:-
const byte pHpin = A0;// Connect the sensor's Po output to analogue pin 0.
6
{
  lcd.init();
  lcd.backlight();
}
void loop()
{
        if (millis() - marca1 >= 1000) {// Take 10 reading per second.
          marca1 = millis();
          // Clear the trigPin by setting it LOW:
          digitalWrite(trigPin, LOW);
      
          delayMicroseconds(5);
      
          // Trigger the sensor by setting the trigPin high for 10 microseconds:
          digitalWrite(trigPin, HIGH);
          delayMicroseconds(10);
          digitalWrite(trigPin, LOW);
      
          // Read the echoPin. pulseIn() returns the duration (length of the pulse) in microseconds:
          duration = pulseIn(echoPin, HIGH);
      
          // Calculate the distance:
          distance = duration * 0.034 / 2;}

    
          lcd.clear();
          lcd.setCursor(1, 1);
          lcd.print("Parametros del agua:");

       
          lcd.setCursor(2, 1);
          lcd.print("pH=" );
          lcd.print(Po);

           lcd.setCursor(3, 1);
          lcd.print("Distancia=" );
          lcd.print(distance);
          
    } 
 
  

Este código no tiene setup por ende no compila.
Postea todo el codigo o mas simple, busca un ejemplo de la libreria y intenta correrlo.
Luego compara con el tuyo y saca conclusiones.

Tal vez esto sea el setup y se te cambió por el 6

6
{
  lcd.init();
  lcd.backlight();
}

Tu código algo mas ordenado

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

//Crear el objeto lcd  dirección  0x3F y 16 columnas x 2 filas
LiquidCrystal_I2C lcd(0x27,20,4);  //
 
// variales temporales
unsigned long marca1, marca2;

// Define Trig and Echo pin:
#define trigPin 2
#define echoPin 3

// Define variables:
long duration;
int distance;
float Po;

// Constantes:-
const byte pHpin = A0;// Connect the sensor's Po output to analogue pin 0.

long ultrasonico() {
	long tmp;
	
	// Clear the trigPin by setting it LOW:
	digitalWrite(trigPin, LOW);
	delayMicroseconds(5);
	// Trigger the sensor by setting the trigPin high for 10 microseconds:
	digitalWrite(trigPin, HIGH);
	delayMicroseconds(10);
	digitalWrite(trigPin, LOW);

	// Read the echoPin. pulseIn() returns the duration (length of the pulse) in microseconds:
	tmp = pulseIn(echoPin, HIGH);

	// Calculate the distance:
	return tmp * 0.034 / 2;
}


void setup () {
  lcd.init();
  lcd.backlight();
}

void loop(){
	
	if (millis() - marca1 >= 1000) {// Take 10 reading per second.
		marca1 = millis();
		distancia = ultrasonico();

		lcd.clear();
		lcd.setCursor(1, 1);
		lcd.print("Parametros del agua:");

		lcd.setCursor(2, 1);
		lcd.print("pH=" );
		lcd.print(Po);

		lcd.setCursor(3, 1);
		lcd.print("Distancia=" );
		lcd.print(distance);
	}	
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.