You are in luck, because a long while ago another person had a similar problem, and I helped him with the code.
const byte buttonPin1 = 2; // Up button
const byte buttonPin2 = 3; // Down Button
boolean buttonState1 = 0;
boolean lastReading1 = 0;
boolean buttonState2 = 0;
boolean lastReading2 = 0;
unsigned long onTime1 = 0, onTime2 = 0;
unsigned long interval = 1000;
unsigned long holdAmount = 5;
int count = 0, lastCount;
void setup() {
//pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
Serial.begin(115200);
}
void loop()
{
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState1 == HIGH && lastReading1 == LOW)
{
onTime1 = millis();
count < 60 ? count++ : count = 0;
}
if (buttonState2 == HIGH && lastReading2 == LOW)
{
onTime2 = millis();
count > 0 ? count-- : count = 59;
}
//held
if (buttonState1 == HIGH && lastReading1 == HIGH)
{
if ((millis() - onTime1) > interval )
{
onTime1 = millis();
count < 60? count += holdAmount : count = 0;
lastReading1 = LOW;
}
}
if (buttonState2 == HIGH && lastReading2 == HIGH)
{
if ((millis() - onTime2) > interval )
{
onTime2 = millis();
count > 0 ? count -= holdAmount : count = 59;
lastReading2 = LOW;
}
}
if(count != lastCount)
{
Serial.println(count);
lastCount = count;
}
lastReading1 = buttonState1;
lastReading2 = buttonState2;
}