Simple test¶
Ensure your device works with this simple test.
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
7import board
8import adafruit_pcf8574
9
10print("PCF8574 digitalio LED blink test")
11
12i2c = board.I2C() # uses board.SCL and board.SDA
13# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
14pcf = adafruit_pcf8574.PCF8574(i2c)
15
16# get a 'digitalio' like pin from the pcf
17led = pcf.get_pin(7)
18
19# Setup pin7 as an output that's at a high logic level default
20led.switch_to_output(value=True)
21
22while True:
23 led.value = True
24 time.sleep(0.2)
25 led.value = False
26 time.sleep(0.2)