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