Created
November 7, 2019 02:20
-
-
Save juanino/d27c1442592d59270ef513bfbacf5d13 to your computer and use it in GitHub Desktop.
test mcp23017 - 9 of the 16 pins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import pprint | |
import board | |
import busio | |
from digitalio import Direction | |
from time import sleep | |
from adafruit_mcp230xx.mcp23017 import MCP23017 | |
i2c = busio.I2C(board.SCL, board.SDA) | |
pp = pprint.PrettyPrinter(indent=4) | |
mcp = MCP23017(i2c) | |
pins = {} | |
for x in range(0,8): | |
pins[x]=mcp.get_pin(x) | |
pins[x].direction = Direction.OUTPUT | |
for x in range(0,8): | |
pins[x].value = True | |
print(x, pins[x].value) | |
sleep(.1) | |
for x in range(0,8): | |
pins[x].value = False | |
print(x, pins[x].value) | |
sleep(.1) | |
for x in range(0,99): | |
for x in range(0,8): | |
pins[x].value = True | |
print(x, pins[x].value) | |
sleep(.4) | |
for x in range(0,8): | |
pins[x].value = False | |
print(x, pins[x].value) | |
sleep(2) | |
sleep(1) | |
# the old twinkle loop | |
''' | |
while True: | |
for x in range(0,8): | |
pins[x].value = True | |
print(x, pins[x].value) | |
sleep(.1) | |
pins[x].value = False | |
sleep(.1) | |
''' | |
# pp.pprint(pins) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment