Help the code works but the lcd will display nothing

Is it something wrong with the code
please help.
Here's the code

//Use "digitalRead();""
#include <LiquidCrystal.h>

int inPin1 = 7;
int inPin2 = 8;

const int rs = 12, en = 11, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  pinMode(inPin1,INPUT);
  pinMode(inPin2,INPUT);
}

void loop() {
  
 digitalRead(inPin1);
 digitalRead(inPin2);
 
   if (inPin1 == HIGH){
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Output");
     lcd.setCursor(0,1);
     lcd.print("1");
    }
  digitalRead(inPin2);
   if (inPin2 == HIGH){
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Output");
     lcd.setCursor(0,1);
     lcd.print("2");
    }
    delay(100);
}

Have you tried the LCD with the example sketches from the LCD library?

Yes

PIUS1212:
Yes

May I inquire as to the result? :slight_smile:

Ok

Great. Look for differences between your sketch (which is mercifully short), and the example sketch.

It looks like you have switches of some kind. Have you also tested them separately with a simple test sketch?

Is it wired right? Is the contrast pot adjusted? That happened to me before....

Nope All correct wiring

It looks like you have switches of some kind. Have you also tested them separately with a simple test sketch?

yes

I was just saying... we can't really see it so we have to trust you. I'm not saying that you're incapable. I'm just speaking from my own experiences. It's easy to forget the grd on the pot.

PIUS1212:
yes

Then look for differences between your (mercifully short) switch test sketch, and this one.

Edit - please post your switch test sketch.

LandonW:
I was just saying... we can't really see it so we have to trust you. I'm not saying that you're incapable. I'm just speaking from my own experiences. It's easy to forget the grd on the pot.

He said that the LCD example sketch works. If so, there shouldn't be an LCD hardware problem.

that makes sense. I was just saying, my last LCD project had no error codes (the code worked) but no display and the pot was my problem. I've also seen a lot of other posts that have similar reasons for not working.

Weird
..

Please post your switch test sketch.

Does the digitalread need to be stored in a variable like say val =

The way you have used it, yes.
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);

Then
if (val1 == HIGH){
// do something 1
}

Alternately,
if (digitalRead(inPin1) == HIGH){
// do something 1
}