Hello, I am fairly new to arduino and started getting a bit more advanced so I had decided to make a digital clock that was able to be manually set using pushbuttons. One issue I ran into was that the buttons were not working as intended and that there was a type of delay to update the time when you push the button or it would not update at all. I was wondering if anyone would be able to help me figure out the problem with my code and or wiring?
#include <LiquidCrystal.h>
int seconds = 0;
int minutes = 0;
int hours = 0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2); // Set up the number of columns and rows on the LCD.
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
// Print a message to the LCD.
lcd.print("Time in: Miami");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(hours);
lcd.print(":");
lcd.print(minutes);
lcd.print(":");
lcd.print(seconds);
lcd.print("__________");
if(seconds < 60){
delay(1000);
seconds = seconds + 1;
}else{
seconds = 0;
}
if(seconds > 59){
minutes = minutes + 1;
}else{
minutes = minutes;
}
if(minutes < 60){
minutes = minutes;
hours = hours;
}else{
minutes = 0;
hours = hours + 1;
}
if(hours < 24){
hours = hours;
}else{
hours = 0;
minutes = 0;
seconds = 0;
}
if(digitalRead(A0) == LOW){
minutes = minutes + 1;
seconds = 0;
}
if(digitalRead(A1) == LOW){
hours = hours + 1;
}
}//loop1