16x2 display issue

I'm trying to use an lcd display to show the level of water depending on how deep the sensor is in but I'm having trouble with the display, it doesn't show the text instead, I'm getting boxes at the top.
Here's the code:

#include <LiquidCrystal.h> 
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 
int pin_sensor = A3;
int water_level;
int lvl;
int led_rojo = 2;
const int buzzer = 3;

void setup() { 
pinMode(pin_sensor, INPUT);
lcd.begin(16, 2);
pinMode (buzzer, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}

void loop() { 
water_level = analogRead(A3); //Lee el sensor 
lvl = map(water_level, 0, 350, 0, 100); //Mapeo de los valores que puede tomar el sensor
lcd.setCursor(2, 0);
lcd.print("Water Level"); 
lcd.setCursor(5, 1); 
lcd.print(lvl);
lcd.print(" %");
delay(300);
digitalWrite(2, LOW);
digitalWrite(3,LOW);

 
if (lvl>=90){
  digitalWrite(2, HIGH);
  for (int i=200;i <= 500; i++){
    tone(buzzer, i);
    delay(5);
  }
  delay(1000);
  for(int i=500; i>=200; i--){
    tone(buzzer, i);
    delay(5);
}
}else if(lvl<90){
  noTone(buzzer);
  
 }
}

What Arduino?

Please post a schematic. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.

Post better photos showing the wiring, please.

Please read the forum guidelines to get information on making a good post.

I'm using Arduino UNO from ELEGOO
the power supply is the computer i'm using and a 9V Battery
I did a schematic for the project

There should be no resistor between Vcc of the LCD and Vcc of the Uno.

image

Ohh thank you

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