Main Site Documentation

Cobra 2 interupt buttons


Hi all, I have 2 interrupt buttons that I have plugged into a breakout board. the buttons are the same as the ones on the board itself that I stole out of an old DVD drive. They look to have a single power in and a ground.
What pins should I use to connect these buttons? I have tried AD5/6 and P1_1+P1_0 via the breakout board.

//slot 4 pin 6 and 7
private InterruptPort leftButton = new InterruptPort(Pin.P1_0, true, Port.ResistorMode.PullDown,
        private InterruptPort rightButton = new InterruptPort(Pin.P1_1, true, Port.ResistorMode.PullUp,
//above throws an System.ArgumentException

I have also tried it on PWM/AD pins.
My question is what type of pin should I be connecting them to? I2C? COM? PWM? Analog?


Physically, if you want to use InterruptPorts, then they need to be connected to a socket type that has interrupt capable pins, and you need to connect to those interrupt capable pins.

Check out this
to help you identify the sockets that you have access to and their pins. I haven’t found a definitive list that says what other pins on the long-edge connector are interrupt capable; that might be something GHI’s documentation guru has sitting on a sideline somewhere, or that he can magic together for us :wink:


Thanks Brett.
Looks like I need one of the pins with a “!” however I tried it on one and when I call leftButton.Read() its always true.
any ideas?


yep. InterruptPort is best handled when using an interrupt handler. Don’t be too hung up on using Read(). If you’re not already doing that, then I suggest looking at the joystick or button module driver code on and follow their pattern.

Other thought, just trigger on one edge not both. See if that helps.


That worked, both Read() and the leftButton_OnInterrupt works now:

 private InterruptPort leftButton = new InterruptPort(Pin.P2_21, true, Port.ResistorMode.PullUp,