COUNTING RISING OR FALLING EDGE OF PULSE

I want to count rising and falling pulse within a time set by another pulse.I am not much familiar with arduino coding so it will be helpful if meaning of code is written with that.

the code i used is too simple and it's actually not counting rising and falling but whenever input is high counts are increasing although by adding delay of almost same of pulsewidth can get rid of redundent counting but i guess it's not a good idea. please someone suggest me how to count only rising and falling edge. Thanks in Advance :slight_smile:
Here is code i have used

const int inputPin = A3;
const int currentPin = A1;
const int input = 3;
unsigned int COUNT = 0;
unsigned int voltage = 0;
unsigned int current = 0;
volatile byte state = LOW;

void setup() {
Serial.begin (9600);
pinMode(input, INPUT);
}
void loop() {
repeat: voltage = digitalRead(input);
if(voltage>0)
{
COUNT = COUNT+1;
delayMicroseconds(500);
}
else {
COUNT = COUNT;
}
current = analogRead(currentPin);
if(current > 900)
{
Serial.println(COUNT);
delay(1000);
COUNT = 0;
}
else {
goto repeat;
}
}

If you're looking for edges, why are you using slow analogue reads?
If you're looking for edges, why have you got delays?
Why "goto"?

Why is your title so SHOUTY?

Start by looking at the StateChangeDetection example in the IDE

To clarify please: You have 2 pulse trains lets call them long and short, and what you want to do is count the shorts inside each long?

Is that right?

So when long goes high, count the shorts until long goes low again?