Problem with 16x2 LCD display

I found a ton of previous threads about "Problems with LCD display", but none that include what's goin on with mine.

I hooked everything up as per the adafruit tutorial...

...and noticed the backlight working when I powered up. However, when I went to adjust the contrast pot, nothing happened. I de-soldered the pot (5k trim pot), and when I checked the trace that was soldered to the wiper, I was getting 5v. ????

How could +5v be coming FROM pin 3 of the LCD?

Below are my Arduino pin assignments...
RS - Pin 5 D5 - Pin 8
EN - Pin 6 D6 - Pin 9
D4 - Pin 7 D7 - Pin 10

Other LCD pins...
16 - Grnd
15 - +5v with 100ohm series resistor
5 - Grnd
3 - Wiper on contrast pot
2 - +5v
1 - Grnd

LCD pins 10, 9, 8, and 7 are not connected to anything, as per the tutorial.

Also, I checked the contrast pot after I de-soldered it, and it was functioning properly. (Wiper showed 0ohms when all one direction, 5kohm when all the other way, and steadily changing in between.)

If +5v is coming FROM pin 3, does that mean I have a bad LCD? Thanks in advance.

I forgot to include the LCD model.

If +5v is coming FROM pin 3, does that mean I have a bad LCD? Thanks in advance.

That would be determined by the (unknown) circuitry within the LCD module. You would be better off measuring the voltage at pin 3 with the potentiometer connected normally. You should be able to adjust it between 0 and 5 V with the optimum setting typically around 0.3 V. Make sure that the power (pins 1 and 2) is connected as well before doing this test.

With just pins 1, 2 and 3 connected you should see one row of blocks on your display. With a white on blue display you will probably need to connect the backlight to make the display visible although it may be barely discernible without the backlight.

Don

Thanks for help. Re-soldered pot in. Checked all connections. Plugged in and worked, although I have no idea what changed.

Ok, now I need a little help with code. I found an example that's fairly close to what I'm trying to do, but it hasn't worked out for me. The only thing that's not working is displaying the position of a potentiometer in terms of percent. I'm not doing something right as far as the very simple math function goes.

// Include liquid crystal library
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(5, 6, 7, 8, 9, 10);

#define LED  13  // the pin for the led
#define HALLSWITCH  12 // the pin for the hall switch

// Set analog pin 1 as venier control
// Venier control sets how long solenoid is energized
int venierPin = 1;
int venierValue = 1;

// Set constant for using vernier setting to determine time
// to energize soleniod
const int constvenierValue = 2;

// val will be used to store the state of the input pin
int val = 0;

// store previous state
int old_value = 0;

// 0 = LED off and 1 = LED on
int state = 0;

int percent = 1;

void setup() {
  // initialize digital pins
  pinMode(LED, OUTPUT);
  pinMode(HALLSWITCH, INPUT);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print "Vernier Setting" to the LCD
  lcd.print("Vernier Setting");
  // Print percent symbol to the LCD
  lcd.setCursor(6, 1);
  lcd.print("percent");
}
  
  void loop() {
    // read venier setting
    venierValue = analogRead(venierPin);
    
    percent = ((venierValue/1024)*100);
    
    // print pot position percent to LCD screen
    lcd.setCursor(0,1);
    lcd.print(percent);
    
    // read hall effect state
    val = digitalRead(HALLSWITCH);
    
    // designate when to turn on and off
    if ((val == HIGH) && (old_value == LOW)) {
      state = 0;
    // debounce
    delay(10);
    }
    
    if (state == 0) {
      digitalWrite(LED, HIGH); // turn on LED
      delay((venierValue / constvenierValue) + 30); // LED on some time
      digitalWrite(LED, LOW); // LED off
      state = 1;
    } else {
      digitalWrite(LED, LOW);
      delay(10);
    }
    old_value = val;
  }

If you'll look 3 lines down after beginning the loop, you can see how i'm trying to display the position of the pot as a percent. The hardware is all good, as I can replace the math function with "venierValue" and it will display a value between 0 and 1024 that changes as I turn the pot. Great. With the code I have presented above, it just displays a value of 0 no matter the pot position. I've tried writing it a bunch of different ways and I'm not good at programming. Thanks in advance.

One other bridge I've yet to cross is that once I cross into a new decimal place, ie 999 to 1000, the "1" will remain as I turn the pot back down. If this is an easy fix, please include in response. Thank you.

One other bridge I've yet to cross is that once I cross into a new decimal place, ie 999 to 1000, the "1" will remain as I turn the pot back down. If this is an easy fix, please include in response. Thank you.

I can help you with this part.

As you have discovered, once you write a character to the LCD it stays there until it is overwritten. Therefore to 'erase' a character such as your residual '1' you have to overwrite it with a 'space'.

One way to deal with displaying changing data is to:
(1) position the cursor
(2) display enough spaces to cover up all of the earlier data
(3) reposition the cursor
(4) display your new data

Another way is shown here: sprintf | LiuDr Electronic Solutions LLC Official Blog

Don

If I'm following you correctly, an easy fix would be to put this at the end of the loop...

lcd.setCursor(0,1);
lcd.print(" ");

Thanks. Now if I could get a little help on the other part I'll be set. I'm currently digging a toasted hall effect out of a block I machined
and filled with silicon to hold it in place. FUN! FUN! Thanks again.

If I'm following you correctly, an easy fix would be to put this at the end of the loop...

That should work although I personally would put it just before the steps where you display the data. That way all the pertinent steps are together. It also makes things easier if you decide to only write data when it is different from the previously written data.

Don

I'm down with that. Thanks.

You have to realize that integers do integer math. If you divide 1023/1024, you get 0 and 0 * 100 =0. That's why your percent calculation isn't working. Instead of:

percent = ((venierValue/1024)*100);

try this:

percent = ((venierValue*100)/1024);

Thanks John, I'm at least getting some numbers now. However, they cycle through negative and positive values ranging from 0 - 31. I searched some old threads and am wondering...

Do I need to do an "itoa" conversion to display the values properly?

I would have just tried it, but I don't know anything about it and would require some extensive reading. I'd like to know if I'm headed down the right path or not before I put a lot of time into it.

Thanks