Skip to content

Example using interrupts  #1

Description

@haexperts2020

I am trying to add an interrupt to pin 0 on the chip and then on my pi pin 16 listens for the interrupt from one of the interrupt pins on the chip. I think I am close. Right now I can see the button presses but no interrupts fire.

from mcp230xx import MCP230XX

import time, os
import RPi.GPIO as IO

IO.setmode(IO.BCM)
IO.setup(21, IO.IN, pull_up_down=IO.PUD_UP)

MCP = MCP230XX('MCP23017', 0x27, '16bit')
MCP.set_mode(0, 'input', 'enable')

MCP.interrupt_options(outputType = 'activehigh', bankControl = 'both')
	
def functA():
	print('abc')

def functB():
	print('efg')

MCP.add_interrupt(0, callbackFunctLow=functA, callbackFunctHigh=functB) 

IO.add_event_detect(16, IO.FALLING, callback = MCP.callbackBoth)

while True:
	print(MCP.input(0))
	time.sleep(.2)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions