need help with lcd

hi there, im trying to get a lcd to count how many times I press a button. I found a sketch on the internet showing me what to do and giving the code, but I cant seam to get it working. iv tried changing around some wires and trying to change the code slightly this hasent worked.
this is the link to where I got the code.

this is the code I have been using

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// set up a constant for the tilt switchPin
const int switchPin = 6;

int hits = 0;

// variable to hold the value of the switchPin
int switchState = 0;

// variable to hold previous value of the switchpin
int prevSwitchState = 0;

void setup() {
// set up the number of columns and rows on the LCD
lcd.begin(16, 2);

// set up the switch pin as an input
pinMode(switchPin,INPUT);

lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Hit the button”);
lcd.setCursor(0, 1);
lcd.print(“to increment”);
}

void loop() {
// check the status of the switch
switchState = digitalRead(switchPin);

// compare the switchState to its previous state
if (switchState != prevSwitchState) {
if (switchState == LOW) {
hits = hits + 1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Hits:”);
lcd.setCursor(0, 1);
lcd.print(hits);
}
}
// save the current switch state as the last state
prevSwitchState = switchState;
}

below is a picture of what im getting on the screen. the 8 will count up but wont count in order it goes 0 2 1 3 4 6 5 7 8 : then the 4 will change to 5, 6 ect
is my wiring wrong or the code. all I want is to display a word and the number to count up in order.
any help would be gret, thanks

Please go back and edit your post to use code tags, </> in the menu.

The sketch isn’t great but it should work. So go back to the basics first. Open the Hello world LiquidCrystal example and try that. Probably you have the wiring wrong. Check, recheck, rerecheck, Google, rererecheck etc

You have not taken switch bouncing into consideration: https://www.pololu.com/docs/0J16/4

So the logic is that, IF switchStateChanged(eg. LOW to HIGH) ===> wait 25ms ===> is switchState Still Changed?(Still HIGH) ===>Count as hit (hits++)

if (buttonState != lastButtonState) { // if the state has changed, increment the counter
              
    delay(25); //25ms delay to avoid bouncing
    
    if (buttonState == HIGH) {
                   // if the current state is still HIGH(after 25ms) then 
                   // increment hit
      hits++; 
    }
     
  }

Also see this: https://www.arduino.cc/en/Tutorial/Debounce

That's completely true, but that's step two. Even with switch bounce the LCD should produce readable text. Not VqSJZ_8H VX9stZ4 :p

septillion: That's completely true, but that's step two. Even with switch bounce the LCD should produce readable text. Not VqSJZ_8H VX9stZ4 :p

Oh, then there definately is a wiring mistake. Are you sure 12 is RS, 11 is Enable and 5,4,3,2 is D4,D5,D6 and D7 respectively? Please confirm

thanks for the help. Ill try changing about some of the wiring and see can I get it to work. im new enough to the arduino so not great with code wrighting and wiring