Problem with butttons and i2c lcd

Hey im making a braille alphabet with servos and 3 buttons the first is to change the letters upwards for example a,b,c and the second one is to do it backwards e.g. c,b,a etc. and the third one is the enter you can view the letters on the lcd but i have some problems with it
one of which is that it shows a little of gibberish and when i click the buttons it cycles thru the letters and i cant think of a way to make the enter work here is the code please help me!
</>

// Добавя се библиотеката на серво моторите
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
// Даваме индентифиционен номер/име на серво моторите
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

const int buttonPin1 = 2;
const int buttonPin2 = 4;
const int buttonPin3 = 7;

char str[] = "abcdefghijklmnopqrstuvwxyz";

LiquidCrystal_I2C lcd(0x27, 16, 2);

int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;

char val;
int letter = 0;
bool print = false;

//Позиция на сервотата в градуси
int down = 0;
int up = 90;

void setup()
{

lcd.begin();


lcd.backlight();
lcd.clear();

pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);

/// Serial.begin(9600); // Serial comm begin at 9600bps

//Казваме къде са включени сервотата (3-5-6-9-10-11)
servo1.attach (3);
servo2.attach (5);
servo3.attach (6);
servo4.attach (9);
servo5.attach (10);
servo6.attach (11);

servo1.write(down);
servo2.write(down);
servo3.write(down);
servo4.write(down);
servo5.write(down);
servo6.write(down);
}

void loop() {
lcd.setCursor(0, 0);
lcd.print("Choose a letter:");
lcd.setCursor(0, 1);

buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState2 = digitalRead(buttonPin3);
if (buttonState1 == HIGH) {
letter=letter+1;
buttonState1 == LOW;
}

if (buttonState2 == HIGH) {
letter=letter-1;
buttonState2 == LOW;
}
// lcd.setCursor(0, 0);

// lcd.setCursor(0,1);
// lcd.print(val);

if (buttonState3 == HIGH) {
print=true;
lcd.setCursor(0, 0);
lcd.print("A letter has been entered!");
}

switch (letter){
case 1:
lcd.print('a');
val = 'a';
break;

case 2:
lcd.print('b');
val = 'b';
break;

case 3:
lcd.print('c');
val = 'c';
break;

case 4:
lcd.print('d');
val = 'd';
break;

case 5:
lcd.print('e');
val = 'e';
break;

case 6:
lcd.print('f');
val = 'f';
break;

case 7:
lcd.print('g');
val = 'g';
break;

case 8:
lcd.print('h');
val = 'h';
break;

case 9:
lcd.print('i');
val = 'i';
break;

case 10:
lcd.print('j');
val = 'j';
break;

case 11:
lcd.print('k');
val = 'k';
break;

case 12:
lcd.print('l');
val = 'l';
break;

case 13:
lcd.print('m');
val = 'm';
break;

case 14:
lcd.print('n');
val = 'n';
break;

case 15:
lcd.print('o');
val = 'o';
break;

case 16:
lcd.print('p');
val = 'p';
break;

case 17:
lcd.print('q');
val = 'q';
break;

case 18:
lcd.print('r');
val = 'r';
break;

case 19:
lcd.print('s');
val = 's';
break;

case 20:
lcd.print('t');
val = 't';
break;

case 21:
lcd.print('u');
val = 'u';
break;

case 22:
lcd.print('v');
val = 'v';
break;

case 23:
lcd.print('w');
val = 'w';
break;

case 24:
lcd.print('x');
val = 'x';
break;

case 25:
lcd.print('y');
val = 'y';
break;

case 26:
lcd.print('z');
val = 'z';
break;

}

if (letter ==27)
{
letter =0;
}

if (letter ==-1)
{
letter =26;
}

//val=letter

///if (Serial.available()) // if serial value is available

///{ val = Serial.read(); // then read the serial value
if(print == true)
{
if (val == 'a' or val == 'b' or val == 'c' or val == 'd' or val == 'e' or val == 'f' or val == 'g' or val == 'h' or val == 'k' or val == 'l' or val == 'm' or val == 'n' or val == 'o' or val == 'p' or val == 'q' or val == 'r' or val == 'u' or val == 'v' or val == 'x' or val == 'y' or val == 'z')
{
servo1.write(up);
}

if (val == 'b' or val == 'f' or val == 'g' or val == 'h' or val == 'i' or val == 'j' or val == 'l' or val == 'p' or val == 'q' or val == 'r' or val == 's' or val == 't' or val == 'v' or val == 'w')
{
  servo2.write(up);
}

if (val == 'k' or val == 'l' or val == 'm' or val == 'n' or val == 'o' or val == 'p' or val == 'q' or val == 'r' or val == 's' or val == 't' or val == 'u' or val == 'v' or val == 'x' or val == 'y' or val == 'z')
{
  servo3.write(up);
}

if (val == 'c' or val == 'd' or val == 'f' or val == 'g' or val == 'i' or val == 'j' or val == 'm' or val == 'n' or val == 'p' or val == 'q' or val == 's' or val == 't' or val == 'w' or val == 'x' or val == 'y')
{
  servo4.write(up);
}

if (val == 'd' or val == 'e' or val == 'g' or val == 'h' or val == 'j' or val == 'n' or val == 'o' or val == 'q' or val == 'r' or val == 't' or val == 'w' or val == 'y' or val == 'z')
{
  servo5.write(up);
}

if (val == 'u' or val == 'v' or val == 'w' or val == 'x' or val == 'y' or val == 'z')
{
  servo6.write(up);
}


delay(5000);
servo1.write(down);
servo2.write(down);
servo3.write(down);
servo4.write(down);
servo5.write(down);
servo6.write(down);

}
print = false;
}
'''
</>

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the </> icon above the compose window) to make it easier to read and copy for examination

Please post your code as requested by @UKHeliBob. Also a wiring diagram is required to help you get this working.

In particular:

  1. How are your buttons wired?
  2. How are your servos powered?

A complete and concise description of EXACTLY how you want your program to operate would be helpful as well as a description of EXACTLY what the program is actually doing or not doing.

Im trying but it doesnt work

Im powering the servos from the 5v from the arduino

Servos need a separate power supply. It is likely when the servos start moving it will cause the Arduino to reset because of voltage drop.

In the code below you are checking for the state of the button rather than the change in state of the button (i.e., not pressed -> pressed). This in combination with the 5s delay in your code means that you have to hold the a button and release it at exactly the right time to cause an action to happen. Study the following tutorials:

StateChangeDetection
Example-code for timing based on millis()
BlinkWithoutDelay

  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState2 = digitalRead(buttonPin3);
  if (buttonState1 == HIGH) {
    letter = letter + 1;
    buttonState1 == LOW;
  }

  if (buttonState2 == HIGH) {
    letter = letter - 1;
    buttonState2 == LOW;
  }
  // lcd.setCursor(0, 0);

  // lcd.setCursor(0,1);
  // lcd.print(val);

  if (buttonState3 == HIGH) {
    print = true;
    lcd.setCursor(0, 0);
    lcd.print("A letter has been entered!");
  }

The following code:

  switch (letter) {
    case 1:
      lcd.print('a');
      val = 'a';
      break;

    case 2:
      lcd.print('b');
      val = 'b';
      break;
      .
      .
      .
    case 26:
      lcd.print('z');
      val = 'z';
      break;
  }

can be replaced by:

  val = 'a' + letter;
  lcd.print(val);

maybe val = 'a' + letter - 1 ; ?

Oopsie! Yes you are correct. Although I would recommend starting with 0 rather than 1, per convention.

can you help me with

if (buttonState1 == HIGH) {
   letter = letter + 1;
   buttonState1 == LOW;
 }

 if (buttonState2 == HIGH) {
   letter = letter - 1;
   buttonState2 == LOW;
 }

right now when i hold it it cycles thru the letters i want to make it so each press is diffrent letter

also the third one should send the letter to the servos so they can rotate sorry about the code but i cant format it

That is why I referred you to the StateChangeDetection tutorial in post #7.

 buttonState1 == LOW;

did you mean

 buttonState1 = LOW;

Not that I think it will help

You need to detect when the button [color = red]becomes[/color] pressed rather than when it [color = red]is[/color] pressed
See the StateChangeDetection example in the IDE
guide[/url], [url=Arduino Forum?

Ok but how am i going to make it so that when i hit the 3rd button or 'enter' it sends the letter to the servos

Have you already got as far as being able to display a specific letter in the LCD screen by pressing button 1 and button 2 ?
At the time at which you are ready to press the third button, the value of the selected letter is already stored in a variable. Is that correct? If so, you examine that variable and detemine which of the servos are to be activated and send the appropriate commands. It looks like you already have code which can operate the correct servo sequence for each letter.

It shows the selected letter and i think its stored in val but im not sure what i have to do to go further

You have a typing error here in your code from post #1 :

buttonState2 = digitalRead(buttonPin2);
buttonState2 = digitalRead(buttonPin3);  /surely you meant buttonState3

Once you have corrected that, you'd do something like this:

if ( buttonState3 == HIGH ) {  // assuming that when the button is pressed, it is read as HIGH 
  delay( 100 ) ; // crude debounce - to be optimised later
  // use Serial.print() for debugging to the serial monitor. You need to define Serial.begin() in function setup().
  Serial.print( "val=" ) ;  // you've said you are not sure if 'val' contains the correct data so check
  Serial.println( val ) ;
  // now add all that code you have to trigger servo1 through to servo6 based on 'val'.
}