Programable counter and stop

Hello!
I am very new to arduino, and this is my first time programming one, I need to make a counter that can be customizable my the user and have it stop once it reaches the number.
I have the arduino UNO, protoboard and lcd screen for the job, I am missing the number pad and my code works well as a counter.
I just don't know how to make it customizable or how to make it stop counting when it reaches the number.

Any help is greatly appreciated!

The first thing you should do is have a look here.
Then put together your first draft, test it, come bavk to this forum and post your code along with any error message. We're here to assist with your difficulties, not write code for you. The tutorials should give you a good start.

I have read the begginer's guide already, actually I've been looking at turorials and sketches for the past two weeks. I have a code for a counter which I looked up online, it seems to work just fine but I feel there are some innecessary lines there:
#include <Wire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// this constant won't change:
const int Up_buttonPin = 2; // the pin that the pushbutton is attached to
const int Down_buttonPin = 3;
volatile int Counter;

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int up_buttonState = 0; // current state of the up button
int up_lastButtonState = 0; // previous state of the up button

int down_buttonState = 0; // current state of the up button
int down_lastButtonState = 0; // previous state of the up button
bool bPress = false;

void setup()
{
Serial.begin(9600);
pinMode( Up_buttonPin , INPUT_PULLUP);
pinMode( Down_buttonPin , INPUT_PULLUP);

// initialize the lcd

// Print a message to the LCD.
lcd.begin(16, 4);
lcd.setCursor(0,0);
lcd.print("Contador de Pulsos");
lcd.setCursor(2,1);
lcd.print(buttonPushCounter);

}

void loop()
{
checkUp();
checkDown();

if( bPress){
bPress = false;
lcd.setCursor(1,1);
lcd.print(" cm");
lcd.setCursor(1,1);
lcd.print(buttonPushCounter);
}
//This will select the target size based on a physically latching switch

}

void checkUp()
{
up_buttonState = digitalRead(Up_buttonPin);

// compare the buttonState to its previous state
if (up_buttonState != up_lastButtonState) {
// if the state has changed, increment the counter
if (up_buttonState == LOW) {
bPress = true;
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
} else {
// if the current state is LOW then the button went from on to off:
Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
up_lastButtonState = up_buttonState;
}
void checkDown()
{
down_buttonState = digitalRead(Down_buttonPin);

// compare the buttonState to its previous state
if (down_buttonState != down_lastButtonState) {
// if the state has changed, increment the counter
if (down_buttonState == LOW) {
bPress = true;
// if the current state is HIGH then the button went from off to on:
buttonPushCounter--;

Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
} else {
// if the current state is LOW then the button went from on to off:
Serial.println("off");
}
// Delay a little bit to avoid bouncing
delay(50);
}
// save the current state as the last state, for next time through the loop
down_lastButtonState = down_buttonState;
}

the void check up and the void check down seem a little useless for what I need but I'm not sure if I should erase them.
Now, as for my current code, I copied some part of the one above and placed them in the button sketch:
#include <Wire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
/*
This example code is in the public domain.

*/

// constants won't change. They're used here to set pin numbers:
const int Up_buttonPin = 2; // the number of the pushbutton pin
const int Down_buttonPin = 3;
volatile int count = 0;

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonPushCounter = 0; // counter for the number of button presses
int up_buttonState = 0; // current state of the up button
int up_lastButtonState = 0; // previous state of the up button
bool bPress = false;

void setup() {
Serial.begin(9600);
pinMode( Up_buttonPin , INPUT_PULLUP);
pinMode( Down_buttonPin , INPUT_PULLUP);
// Print a message to the LCD.
lcd.begin(16, 4);
lcd.setCursor(0,0);
lcd.print("Contador de Pulsos");
lcd.setCursor(2,1);
lcd.print(buttonPushCounter);
}

void loop() {

// read the state of the pushbutton value:
buttonState = digitalRead(Up_buttonPin);

// check if the pushbutton is pressed. If it is, the buttonState is HIGH:

if ( bPress){
bPress = false;
count++; //add 1 to the count
lcd.setCursor(1,1);
lcd.print(" cm");
lcd.setCursor(1,1);
lcd.print(buttonPushCounter);
}

if (count>=8){
count =0;
lcd.setCursor(1,1);
lcd.print(" cm");
lcd.setCursor(1,1);
lcd.print(buttonPushCounter);
}

}

No errors come up when I verify the code, but when I press the buttons in my protoboard, nothing happens, and I'm not certain of what's causing it

Ok, I've made some progress since yesterday, I looked up online how to rest a counter, read over my code and verified it multiple times... the counter works perfectly, but when I try to use the reset it doesn't work, it just keeps counting:

 if(Counter >= 3){
 Counter =0;
 lcd.setCursor(1,1);
 lcd.print(" 0 cm");
 
  }

No errors come up when I check the code and the arduino accepts it just fine, this code is in the void loop section.

I'm still working on my code, I erased the part of my previous comment and tried adapting many resets from other threads on the forum but it still doesn't work.
My counter keeps on going but it doesn't reset as I need it to.
I got rid of the down button which lowered the count, since it wasn't really needed.

#include <Wire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 


// this constant won't change:
const int  Up_buttonPin   = 2;    // the pin that the pushbutton is attached to
volatile int Counter;

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int up_buttonState = 0;         // current state of the up button
int up_lastButtonState = 0;     // previous state of the up button

bool bPress = false;

void setup()
{
  Serial.begin(9600);
  pinMode( Up_buttonPin , INPUT_PULLUP); 
  // Print a message to the LCD.
  lcd.begin(16, 4);
  lcd.setCursor(0,0);
  lcd.print("Contador de Pulsos");
  lcd.setCursor(2,1);
  lcd.print(buttonPushCounter); 
}

void loop()
{
   checkUp();
   if( bPress){
       bPress = false;
      lcd.setCursor(1,1);
      lcd.print("     cm");
      lcd.setCursor(1,1);
      lcd.print(buttonPushCounter);
   }
}

void checkUp()
{
  up_buttonState = digitalRead(Up_buttonPin);

  // compare the buttonState to its previous state
  if (up_buttonState != up_lastButtonState) {
    // if the state has changed, increment the counter
    if (up_buttonState == LOW) {
        bPress = true;
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  up_lastButtonState = up_buttonState;
}

I've tried everything that I came across with but nothing seems to be working... how do I stop or reset the counter? :sob:

To make it customizable (is that really a word?), you first need to define how that will work. You say you have a keypad (not yet), push-button, serial monitor, these are all methods of user input however, each will be treated differently. The act of resetting is trivial once you've decided on user input and how to deal with it.

Ok, so I solved the counter problem, it finally resets when I reach the desired number, here's the code I used:

#include <Wire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12); 


// this constant won't change:
const int  Up_buttonPin   = 2;    // the pin that the pushbutton is attached to
volatile int Counter;

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int up_buttonState = 0;         // current state of the up button
int up_lastButtonState = 0;     // previous state of the up button

bool bPress = false;

void setup()
{
  Serial.begin(9600);
  pinMode( Up_buttonPin , INPUT_PULLUP); 
  // Print a message to the LCD.
  lcd.begin(16, 4);
  lcd.setCursor(0,0);
  lcd.print("Contador de Pulsos");
  lcd.setCursor(2,1);
  lcd.print(buttonPushCounter); 
}

void loop()
{
   checkUp();
          
   if( bPress){
       bPress = false;
      lcd.setCursor(1,1);
      lcd.print("   cm");
      lcd.setCursor(1,1);
      lcd.print(buttonPushCounter);
   }

   if (buttonPushCounter == 5){ buttonPushCounter = 0;  // reset the count
   lcd.setCursor(1,1);
      lcd.print("5 FIN");
      lcd.setCursor(1,1);
 }         
}

void checkUp()
{
  up_buttonState = digitalRead(Up_buttonPin);
  // compare the buttonState to its previous state
 
  if (up_buttonState != up_lastButtonState) {
    // if the state has changed, increment the counter
   
    if (up_buttonState == LOW) {
        bPress = true;
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes: ");
      Serial.println(buttonPushCounter);
    } else {
      // if the current state is LOW then the button went from on to off:
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  up_lastButtonState = up_buttonState;
}

I left it as readable as possible, but I think it might change when I adapt the keypad to it.

DKWatson, I'd like to mention that I have little to no experience programming anything. I took a small course on app programming over two years ago, and my technical knowledge is null. Of course, I don't expect anyone to just hand me the answers to everything, but I only asked for guidance, and while I understand that it is very easy to misinterpret written messages online, I feel that your comments have confused me more than what they were supposed to help me, and you never adressed my issue or even asked more about it. Of course I'll try to be more specific with any programming difficulties from now on, but thank you for your help, it is always greatly appreciated.

So the code looks okay and you say it works. Well done.