Simple test

Ensure your device works with this simple test.

examples/tca9534_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2# SPDX-FileCopyrightText: Copyright (c) 2021 Milad Hajihassan for Milador
 3# Demo of reading GPIO's status in TCA9534 bus-expander
 4#
 5# SPDX-License-Identifier: MIT
 6
 7from adafruit_bus_device.i2c_device import I2CDevice
 8import board
 9import busio
10import time
11import community_tca9534
12
13# Create I2C bus.
14i2c = busio.I2C(board.SCL, board.SDA)
15
16# Create bus-expander instance.
17tca9534 = community_tca9534.TCA9534(i2c)
18
19
20# Main loop prints the GPIO zero status every half a second:
21while True:
22    gpio_zero_status = tca9534.get_gpio(0)
23    print("GPIO zero status: {0}".format(gpio_zero_status))
24    # Delay for half a second.
25    time.sleep(0.5)