How i can use 2 Push Buttons to increase or decrease value in seven segment

I want to control an ac motor using Relay
i have connected relay to 52 pin of arduino mega.& 4 digit 7 seg display.& 3 push buttons connected on 22,24,36 pin. i set value of 7 seg to 60 min (int CentSec = 60;)
i use 60 min reverce counter. so i want to change the value of (int CentSec = 60;) one button to increase and another to dectease.

Here is code:

#include “SevSeg.h”
const int motor = 52;

const int threshold = 0;
//Create an instance of the object.
SevSeg sevseg;

//Create global variables
unsigned long timer;
int CentSec = 60;

void setup() {
pinMode(motor, OUTPUT);
//I am using a common anode display, with the digit pins connected
//from 2-5 and the segment pins connected from 6-13
sevseg.Begin(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
timer = millis();
Serial.begin(9600);
}

void loop() {
{{
//Produce an output on the display
sevseg.PrintOutput();

//Check if 10ms has elapsed
unsigned long mils = millis();
if (mils - timer >= 100000) {
timer = mils;
CentSec–;
//Update the number to be displayed, with a decimal
//place in the correct position.
sevseg.NewNum(CentSec, (byte) 2);
}
}
{
int analogValue = CentSec;

if (analogValue > threshold) {
digitalWrite(motor, HIGH);

} else {
digitalWrite(motor, LOW);

}

// print the analog value:
Serial.println(analogValue);
delay(1); // delay in between reads for stability
}
}
}

motor.ino (1.29 KB)

void loop() {
  {{

How many curly braces are needed to open a function body? ONE! NOT three. Get rid of the useless curly braces.

Which pins are the switches (NOT buttons) connected to? How are they wired?

Look at the state change detection example. When the up switch becomes pressed, increment CentSec. When the down switch becomes pressed, decrement CentSec.

ravinderrob:
digitPins =2, 3, 4, 5
segmentPins 6, 7, 8, 9, 10, 11, 12, 13
Switch 1 = 22 pin
Switch 2= 24 pin
Relay = 52 pin

So, what have you tried? Every bit of the code you need to add is in the example I pointed you to.

Please edit your post to include code-tags. See How to use this forum. A few Capitals will not hurt…

But yeah, in pseudo code

if(minButton became pressed){ //which is NOT the same as is pressed
  centSec--;
}
else if(plusButton became pressed){
  centSec++;
}

And if you want the easy and neat route, grab a library like Bounce2 to do all the button stuff.

PS. Also changed CentSec to centSec because I (and many others) like to reserve variables starting with a Capital for constants. (To remember us we can’t change them.)