File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change
1
+ from time import sleep
2
+
1
3
import board
2
4
import busio
5
+ from digitalio import Direction , Pull
3
6
from RPi import GPIO
4
- from digitalio import DigitalInOut , Direction , Pull
5
7
from adafruit_mcp230xx .mcp23017 import MCP23017
6
- from time import sleep
7
8
8
9
# Initialize the I2C bus:
9
10
i2c = busio .I2C (board .SCL , board .SDA )
20
21
for pin in range (0 , 16 ):
21
22
pins .append (mcp .get_pin (pin ))
22
23
23
- # Set all the pins to input
24
+ # Set all the pins to input
24
25
for pin in pins :
25
26
pin .direction = Direction .INPUT
26
27
pin .pull = Pull .UP
40
41
41
42
def print_interrupt (port ):
42
43
'''Callback function to be called when an Interrupt occurs.'''
43
- flga = mcp .int_flaga
44
- flgb = mcp .int_flagb
45
- for pin in mcp .int_flag :
46
- print ("Pin number: {} changed to: {}" .format (pin , pins [pin ].value ))
44
+ for pin_flag in mcp .int_flag :
45
+ print ("Interrupt connected to Pin: {}" .format (port ))
46
+ print ("Pin number: {} changed to: {}" .format (pin_flag , pins [pin_flag ].value ))
47
47
mcp .clear_ints ()
48
48
49
49
# connect either interrupt pin to the Raspberry pi's pin 17.
You can’t perform that action at this time.
0 commit comments