Simple test

Ensure your device works with this simple test.

examples/pcf8574_simpletest.py
 1# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
 2# SPDX-FileCopyrightText: Copyright (c) 2022 ladyada for Adafruit Industries
 3#
 4# SPDX-License-Identifier: Unlicense
 5
 6import time
 7
 8import board
 9
10import adafruit_pcf8574
11
12print("PCF8574 digitalio LED blink test")
13
14i2c = board.I2C()  # uses board.SCL and board.SDA
15# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
16pcf = adafruit_pcf8574.PCF8574(i2c)
17
18# get a 'digitalio' like pin from the pcf
19led = pcf.get_pin(7)
20
21# Setup pin7 as an output that's at a high logic level default
22led.switch_to_output(value=True)
23
24while True:
25    led.value = True
26    time.sleep(0.2)
27    led.value = False
28    time.sleep(0.2)