Ghost Interrupt trigger with nothing connected

sorry for my English

the problem:

i have a counter in a function "countpulse" but the counter continue when the sensor is not connected

countpulse 
{
num++
}

in setup:

attachInterrupt(digitalPinToInterrupt(mPinSensor), countpulse , RISING)

callend in the loop:

interrupts();   
  delay(1000);  
  noInterrupts(); 

i am new in arduino sorry.

Welcome to the forum

If nothing is connected to the pin it is floating at an unknown voltage and thus may pick up stray electrical interference which will trigger the interrupt

If you want to prevent this then connect the pin to GND with a 10K resistor to hold it LOW except when the sensor explicitly takes it HIGH

Never leave an input unconnected, it picks up interference and can trigger off that. You always need it in a defined state
See
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

1 Like

What is going to be driving that input? You may be able to use the internal pullup depending on the device generating the input signal.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.