Reseting a variable back to zero

I'm trying to make this counter reset back to zero, but i just can't. I've tried so many ways and can't reset it. Is it wrong the way i am doing this?

Here's the code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE);
 
int sinal=1;
int sensor;
int i = 0;
int reset = 2;

 
void setup() {
 
lcd.begin(16, 2);
pinMode (sinal,INPUT);
pinMode (reset, INPUT);
 
}
 
void loop() {
    
lcd.setCursor(0,0);
lcd.print("CONTADOR DO BAU");
lcd.setCursor(0, 1);
lcd.print("PECA:");
lcd.setCursor(6, 1);
lcd.print(i);
 
sensor = digitalRead(sinal);  
 
while (sensor  == HIGH)
{
sensor = digitalRead(sinal); 
}
 
 
while (sensor  == LOW)
{
sensor = digitalRead(sinal); 
}
 
i++;

if (digitalRead(reset) == HIGH)
{
   i = 0;

}
}

Is "this counter" a cousin of the "andkey-key" ?

Welcome to the forum, and thanks for using code tags on your first post!

However, we are missing some other information, like how the Arduino circuit is wired (post a wiring diagram), what should happen, and what happens instead.

Assuming that the "counter" to which you refer is in the following code fragment, i will not be set to zero if the pin named reset is never set to HIGH.

if (digitalRead(reset) == HIGH)
{
   i = 0;

}

Your 'while' loops are keeping the sketch from doing anything until the 'sinal' pin goes LOW and then goes HIGH. If the 'reset' pin is HIGH at the time the 'sinal' pin goes HIGH again (after being LOW) THEN the counter will reset.

Note: Pins 0 and 1 are the serial interface on the UNO and MEGA so it is good practice to not use them for buttons.

See: File->Examples->02.Digital->StateChangeDetection
This will show you how to count button presses without freezing the rest of the sketch.

Note: You should consider using pinMode INPUT_PULLUP for buttons. Then you don't need an external resistor, just connect the button between the pin and Ground. Closing the button will switch the input from HIGH to LOW which is just as easy to detect as a switch from LOW to HIGH.

Note: Mechanical buttons are noisy. You may get multiple counts per button press. To eliminate the problem you should add some button debounce code.