increment and decrement value using push button

i want to enter the value from one push button and then 2nd push button use to increment that value and third one decrement that value anyone tell me how logic will apply i am a begginer of arduino....

How do you plan on entering a numeric value by pushing a button? Incrementing/decrementing that value by reading another set of push buttons is pretty simple. Try googling "Arduino read a push button"; I got over 950,000 hits. I'll be one of those will show you your answer.

Member jurs provided nice code in reply #8 of this thread to dial in a value on a DFR0009 style LCD.

Nikhil_Goud876:
i want to enter the value from one push button and then 2nd push button use to increment that value and third one decrement that value anyone tell me how logic will apply i am a begginer of arduino....

Is the value to be entered always the same number of digits?

Let's assume that you want to enter a three-digit-value in the range 000 to 999.

Then you could use your first button for selecting the digit to be changed:

1st button, first press == select first digit to be entered (buttons up/down) change this digit)
1st button, second press = select 2nd digit to be entered (buttons up/down) change this digit)
1st button, third press = select 3rd digit to be entered (buttons up/down) change this digit)
1st button, 4th press == save entered value

Something like that?
How to display value? Use a 1602 LCD for visual output?

It sounds to me like this could be implemented as a state machine

state 0  waiting for the start button to be pressed.  Display "Press start button" message
         When it becomes pressed display "Use buttons to increment/decrement value" and enter state 1

state 1  Read increment and decrement buttons
         When one of the buttons becomes pressed increment or decrement the number and display the                                                        
         new value
         Optional - exit back to state 0 if the start button is pressed again
const int buttonPin = 2;    // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
int count=0;
// the following variables are unsigned long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  Serial.begin(9600);
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);

  // set initial LED state
  digitalWrite(ledPin, ledState);
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH),  and you've waited
  // long enough since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;
      

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
          count++;
    Serial.println(count);
      
      }
    }
    }

  // set the LED:
  digitalWrite(ledPin, ledState);

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading;
  }

Please don't cross-post. Threads merged.

i thinking about the dcrement but i don't get get idea if anyone know how i get decrement

Your question doesn't make any sense. Please explain better. To decrement you subtract one. eg.

int i = 5;
i = i - 1;  // decrement i
      if (buttonState == HIGH)
      {

        count++;
        Serial.println(count);
      }

      if (buttonState == HIGH)
      {

        count--;
        Serial.println(count);
      }

If buttonState is HIGH will count be incremented, decremented or both ?

Please post your whole program as it is now.

What have you tried? The state change detection example is all you need to get started.

More threads merged.

How are your switches wired? Using the internal pullup resistors makes wiring so much simpler.

Your code tries to increment the counter only if it is negative, and decrement the counter only if it is positive. Since 0 is neither positive or negative, the value in counter can never change.

         counter = counter ++;

Complete rubbish.

Use counter = counter + 1; OR counter++; Do NOT do this.

AWOL:
More threads merged.

No wonder I am getting confused.
I cannot find where I saw the code that I queried in post #11

Two lots of code from this morning are in the recycle bin - I don't know who put them there.
Do you want me to fish them out?

Do you want me to fish them out?

No thanks. I will comment on the OPs latest code, if at all.

any one help me? i am begginer of arduino i want to increment with one button and decrement with other button i used below code but its its shows negative as well as possitive value at time on serial monitor

const int buttonPin = 2;   
int buttonState;            
int lastButtonState = LOW;   
int count=0;
unsigned long lastDebounceTime = 0;  
unsigned long debounceDelay = 50;  
const int buttonPin1 = 5;   
int buttonState1;            
int lastButtonState1 = HIGH;   
int count1=0;
unsigned long lastDebounceTime1= 0;  
unsigned long debounceDelay1 = 50;  
int reading1;

void setup() {
 Serial.begin(9600);
 pinMode(buttonPin, INPUT);
 pinMode(buttonPin1, INPUT);
}

void loop() {
 int reading = digitalRead(buttonPin);
 if (reading != lastButtonState) {
   
   lastDebounceTime = millis();
  }

 if ((millis() - lastDebounceTime) > debounceDelay) {
  
   if (reading != buttonState) {
     buttonState = reading;
     if (buttonState == HIGH) {
       count++;
   Serial.println(count);
 
   } 
   }lastButtonState = reading;

 } lastButtonState = reading;
   reading1 = digitalRead(buttonPin1);
 if (reading1 != lastButtonState1) {
   
   lastDebounceTime1 = millis();
  }

 if ((millis() - lastDebounceTime1) > debounceDelay1) {
  
   if (reading1 != buttonState1) {
     buttonState1 = reading1;
     if (buttonState1 == HIGH) {
       count1--;
   Serial.println(count1);
 
   } 
   }
 } lastButtonState1 = reading1;
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

@Nikhil_Goud876 will be spending some time away for vandalism.

@Nikhil_Goud876, stop cross-posting. Threads merged.

@Nikhil_Goud876, if you vandalize this forum again I will permanently ban you.

I don't even know what that means.