[SOLVED] White boxes appear instead of text

I got an "Arduino Uno Kit" from a store called Mikroelectron. I'm using the packaged Arduino Uno R3 with the packaged 16x2 LCD, and I connected it with a Capacative Soil Moisture Sensor v1.2.
This is my code:

#include <LiquidCrystal.h>
const int greenled = 12;
const int redled = 11;
const int sensorpin = A0;
const int sensorpower = 8;
const int pump = 9;
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int reading;
int reverse(int num, int start, int end) {
  return end - num + start;
}
void setup() {
  // put your setup code here, to run once:
  pinMode(greenled, OUTPUT);
  pinMode(redled, OUTPUT);
  pinMode(sensorpower, OUTPUT);
  delay(2000);
  lcd.begin(16,2);
  lcd.setCursor(0, 0);
  lcd.print("hello");
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(greenled, LOW);
  digitalWrite(redled, LOW);
  digitalWrite(sensorpower, HIGH);
  delay(100);
  reading = analogRead(sensorpin);
  Serial.println("Reading unmapped:");
  Serial.print(reading);
  Serial.println();
  if (reading >= 870) {
    reading = 870;
  }
  if (reading <= 760) {
    reading = 760;
  }
  reading = map(reading, 760, 870, 0, 100);
  Serial.println("Reading mapped:");
  Serial.print(reading);
  Serial.println();
  reading = reverse(reading, 0, 100);
  delay(25);
  Serial.println("Reading mapped reversed:");
  Serial.print(reading);
  Serial.println();
  delay(10);
  digitalWrite(sensorpower, LOW);

  if (reading > 57) {
    digitalWrite(greenled, HIGH);
  } else {
    digitalWrite(redled, HIGH);
    // analogWrite(pump, 210);
  }

  delay(500);
  // digitalWrite(pump, LOW);
  delay(1000);
}


Image of circuit

edit:
I checked my pins and some of them dont give voltage, very weird

You can ignore everything not in loop(), it's just to show the full code.

Is that big pot on your breadboard connected to the LCD? If it is, then it is likely the contrast control. Turn the pot until the white squares disappear and I think you will be all set.

The squares dissapeared, but no text is displayed.

This tutorial might help:

You're missing the call to lcd.begin(16, 2); in setup(). Without that you can't do anything with the display.

@supastishn
Check your wiring, and show a picture. Your code works.

Hello supastishn

My advice:

You could invest some money to get a I²C adapter.
This will save time for debugging and nerves.

Does not work even with lcd.begin(16,2);
(Edited code to add it)

Same link is in the bottom of the post, but my image is too large

The connections to your LCD must be soldered. You cannot rely on 'dupont' pins stuck through the holes.

Don

The problem isn't with the dupont pins, turned out that it was the actual Arduino pins that were giving out 0 voltage. I'm trying to fix this

And you have all ground pins connected together? If not, that can create strange and erratic errors.

What voltages do you expect, ... on which pin(s), ... and under what conditions?
How are you observing them?

No matter what other problems you may or may not be having the unsoldered pins will still have to be fixed before your display will work reliably.

Don

1 Like

turns out there was an MCU problem, got an i2c, lcd works fine

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