Interrupt triggers under odd conditions

Just wondering if anyone else has had this issue - and if it is an expected behaviour,

When I touch (with my finger, piece of unconnected wire, or metal screwdriver on Pin D5 it triggers the interrupt function).
The desired normal wiring is to have D5 connected to 3V3 with a button in-between the two.

It works when I connect the button inline - but still without pressing the button I can trigger the interrupt by holding my finger or a piece of wire on D6, GND, 3V3.

Oddly enough - when I remove it from the Control Everything PIN out board - it doesn’t seem to have this issue. I suspect the board is damaged or isn’t correctly separating pins. Is my assumption here correct?

I have the below code in setup:

   pinMode(D5, INPUT_PULLDOWN);
    attachInterrupt(D5, muteButtonFunction, RISING);

I have this code in the function:

            mute = 1;
            muteLastTriggered =;
            digitalWrite(D7, HIGH);
            digitalWrite(D7, LOW);
        return 1;

Any thoughts are greatly appreciated!

@Cameron, firstly I need to point out that putting delayMicroseconds(2000000); in an ISR is not a good idea. I suggest you set a flag in the ISR that you sample and reset in loop() and do your actions there.

The INPUT_PULLDOWN on the STM32 is weak, with a typical value of 40K ohms. It doesn’t surprise me that touching your finger may affect the input pin condition. I suggest using plain INPUT and using an external pulldown with a value of 4.7K ohms to avoid this issue. Another approach is to use INPUT_PULLUP , connect the button to GND and set your interrupt for FALLING. You may find this works better since your body will be at a higher potential than ground.


Thank you @peekay123 - that is a great idea. Will try that tonight and see how it goes :smile:

Much appreciated!

1 Like