How do i add 2 push buttons to my lcd clock

Hello, I need help adding 2 push buttons to my 16x2 LCD with i2c. One button is for changing the hour and the other for changing the minutes. I was wondering if you can help me add that part to my code and if you can use pin 7 and pin 8. The wiring is A5 to SCK, A4 to SDA VDD to 5v and VSS to GND. if you need anything else, let me know.

First things firt: which board? UNO R3? Mega?...
Next, if your project has just that I2C LCd, you can use whatever pin you like. Connect one side to the pin, the other to GND. Then on your code use pinMode INPUT_PULLUP (remember, a key press brings it to LOW not HIGH).

Lastly, post here your current code if you need more information.

It is a Arduino Uno R3 and it just has a LCD but I want to add 2 push buttons to to a breadboard to control the time in different time zones.

Have you ever used a button before with the UNO? Have you looked at the examples in the IDE?

no i havent used any buttons before

What type of buttons?

If the buttons have 4 pins, I would recommend using a diagonally opposite pair (either, it does not matter) and leave the other pair unconnected.

You don't need any resistors. Just connect the button between the Arduino pin and ground. In your code, set the pin mode to INPUT_PULLUP. The pin will read HIGH when not pressed and LOW when pressed.

These are 4 pin buttons, and I don't need resisters. Thankyou so much

Do you have the arduino IDE? It should have examples of how to use the buttons. And how to debounce the buttons.

Edited---If you have the arduino IDE, look at FILE->EXAMPLES->DIGITAL->DIGITALINPUTPULLUP. This shows an example of reading a button using the INTERNAL pullup resistor in the UNO. No additional resistor is necessary.

And similarly, FILE->EXAMPLES->DIGITAL->DEBOUNCE shows how to debounce the button using the millis() function. The DEBOUNCE example does uses INPUT instead of INPUT_PULLUP, but you can replace INPUT with INPUT_PULLUP in your code.

I am using IDE 2.2.1 and am unsure if all IDE's have the same examples.

Easy to do:

Ok, so do what I said before. Start connecting the buttons (remember, one side to the pin, the other to GND) then learn how to detect keypresses. To start, you can use an emulator like Wokwi where you can create your own diagram and test it fully before getting your hands on it.

Example diagram (two buttons to pins 2 and 3):

Example code (note: this is just some "raw" untested code to get you started experimenting) where I think/hope you can find some useful things:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);

const byte PIN_BTN[] = {2, 3};
const byte BTN_PRESSED = LOW;

void setup()
{
  Serial.begin(115200);	// Debugging only

  for(int i=0; i<=1; ++i)
    pinMode(PIN_BTN[i], INPUT_PULLUP);

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

  lcd.setCursor(0, 0);
  lcd.print(" - TEST CODE - ");

}

void loop() 
{
  for(int i=0; i<=1; ++i) {
    if(digitalRead(PIN_BTN[i]) == BTN_PRESSED) {
      lcd.setCursor(0, 1);
      lcd.print("Button "); lcd.print(i+1); lcd.print("!");
      delay(50); // Software debounce
      // Wait key release
      while (digitalRead(PIN_BTN[i]) == BTN_PRESSED)
        delay(100);
      lcd.setCursor(0, 1);
      lcd.print("            ");
    }
  }
}

Let me know if you create a Wokwi account, so I can share a link to the project with you so you can open it and add it to your workspace where you can edit it as you like.

EDIT: here is the link to Wokwi project:

Do you not understand that we cannot see your work? Remember the pinned post you read when you were a noob? It told you to post all code in a < CODE/ > block after IDE/Tools/Auto Format, if any compile errors or run time output to also post that in a code block.
Now draw by hand where every wire goes and label the dest, provide datasheets for non-common parts. Now post a picture of thst drawing and check it to make sure it is in focus, if needed task multiple photos of different sections but include one of everythhing.

Start with the builtin and board examples and copy the code in them that relates to your requirements.

Teach a man to fish.

Do you anticipate increasing AND decreasing the values?   If so, a third button would be handy.

Does it make sense that the builtin examples would EVER change? If they did they might be labelled NEW or Version etc. Basics are basics.

I doubt the example codes would change. I just didn't know if more examples have been added over the years.

No idea, but I would not be surprised. If they were, how does that help or hinder you?

As I read your OP you are looking for one of the most common things asked about.
If you start with the button sketch and run it for a while you will likely encounter button/switch bounce. You will know it when it happens.
If you then load the Debounce sketch and run it you will see a different behaviour.
There are dozens of debounce and button libraries available. I suggest you find a few and run their examples until you find one that has an API you like and it is reliable.

???

OP has wanted to connect his buttons on DPin-7 nd 8; where, you have shown on DPin-2 and 3 wit giving any good reason.

???

OP has wanted to connect his buttons on DPin-7 nd 8; where, you have shown on DPin-2 and 3 wit giving any good reason.

The reason is "you can use any pin you want", and together with the word "example" should be enough.

Even the example code I created wasn't exactly suited to the user's project, and while we can assume it's a watch, my "example" code only demonstrates how to intercept key presses and "do something." Also, keep in mind that the user was also confused by the four touch button pins...

Unless the OP shows us his full code and diagram, everything is just an "example". There's no need to be picky.