Incorrect behavior of output in response to digital input

Hello, this is my first post here so i don't know if it is the correct section or not.
Here is the problem:
I have an Arduino Uno board whose input is the output of a comparator from another circuit. I am using digital input as the comparator output will either be 0 V or 4.5-5 V. Then the arduino will produce a high signal for 5 ms and then low for 10 ms. When there is no input from comparator, the arduino doesn't produce anything, which is fine. However, when there is an input, there are additional activation of the output even though i cannot see any input from the comparator on the oscilloscope. That means that i can have three pulses coming from comparator, but the arduino produces 5 outputs instead of just three.
Here is the code i am using:

void setup() {
// put your setup code here, to run once:
pinMode(9,OUTPUT);
pinMode(6,INPUT);

digitalWrite(9,LOW);

}

void loop() {

digitalWrite(9, LOW);
if(digitalRead(6) == HIGH){
digitalWrite(9,HIGH);
delay(5);
digitalWrite(9, LOW);
delay(10);
}
}

appreciate the help

If the pulse length on pin 6 is greater than 15ms you would certainly get additional output pulses. If that is the case then you should be looking for a state change, i.e the rising edge of your input.

The tutorial at https://www.arduino.cc/en/Tutorial/StateChangeDetection should give you some ideas.

Some comparator outputs are open collector and require a pullup resistor. Without the pullup the Arduino input is floating.

Thanks everyone, i appreciate the responses. It turns out, there was an input but because i had the oscilloscope set up to show around 10 seconds, some of the input spikes were not shown.