CoinSlot and CoinHopper , COIN CHANGER CODE

Please help me in my project, pulse value is not returning to 0 when I am ejecting coins from the Hopper this is the code.LAST_NA_LAST_NA.ino (1.6 KB)

const int buttonPin = 6;
const int relayPin = 7;
const int pulsePin = 3;
volatile int counter = 0;
int bill = 0;
bool flg = 0;
int i=0;
// Number of impulses detected
byte impulsCount=0;
// Sum of all the coins inseted
float total_amount=0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin,OUTPUT);
pinMode(relayPin,OUTPUT);
pinMode(pulsePin,INPUT);
attachInterrupt(0,incomingImpuls, FALLING);

}
void incomingImpuls()
{
impulsCount=impulsCount+1;
i=0;
}

void loop() {

if(digitalRead(buttonPin) == HIGH)
{

if(total_amount>=5)
{
  bill = total_amount;
  digitalWrite(relayPin,LOW);
  pulseCount();
  total_amount=0;
  impulsCount=0;
}
Serial.println(bill);
counter = 0;
bill = 0;
impulsCount=0;
total_amount=0;

}
else
{
digitalWrite(relayPin,HIGH);
Coins();
}

}

void pulseCount(){

while(counter<bill)
{
if(digitalRead(pulsePin) == HIGH)
{
flg = 0;
}
else if(flg == 0)
{
flg = 1;
counter++;
}
Serial.println(counter);
}
}
void Coins() {
i=i+1;

Serial.print(“i=”);
Serial.print(i);
Serial.print(" Impulses:");
Serial.print(impulsCount);
Serial.print(" Total:");
Serial.println(total_amount);

if (i>=1 and impulsCount==1){
total_amount=total_amount+5;
impulsCount=0;

}
if (i>=1 and impulsCount==5){
total_amount=total_amount+5;
impulsCount=0;

}
if (i>=1 and impulsCount==10){
total_amount=total_amount+10;
impulsCount=0;

}
}

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code

Please, reword what your problem is.

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

Your ‘impulsCount’ and ‘i’ are not declared ‘volatile’.

‘i’ is a very bad name for a volatile global variable. The name has no meaning.

Comments help us understand the code. I assume it is a coin changer but that is a SWAG. Did I miss something I gather there is no hardware and that this is an exercise in writing code.