def __init__(self, spi, latch, columns, lines, backlight_inverted=False): # pylint: disable=too-many-arguments """Initialize character LCD connected to backpack using SPI connection on the specified SPI bus and latch line with the specified number of columns and lines on the display. Optionally specify if backlight is inverted. """ # pylint: enable=too-many-arguments import adafruit_74hc595 self._shift_register = adafruit_74hc595.ShiftRegister74HC595( spi, latch) reset = self._shift_register.get_pin(1) enable = self._shift_register.get_pin(2) db4 = self._shift_register.get_pin(6) db5 = self._shift_register.get_pin(5) db6 = self._shift_register.get_pin(4) db7 = self._shift_register.get_pin(3) backlight_pin = self._shift_register.get_pin(7) super().__init__(reset, enable, db4, db5, db6, db7, columns, lines, backlight_pin=backlight_pin, backlight_inverted=backlight_inverted)
import time import board import digitalio import adafruit_74hc595 latch_pin = digitalio.DigitalInOut(board.D5) sr = adafruit_74hc595.ShiftRegister74HC595(board.SPI(), latch_pin) # Create the pin objects in a list pins = [sr.get_pin(n) for n in range(8)] while True: for _ in range(2): # Run the chase animation twice for enabled_pin in range(len(pins)): for pin_number, pin in enumerate(pins): if pin_number == enabled_pin: pin.value = True else: pin.value = False time.sleep(0.01) for _ in range(3): # Run the blink animation three times for pin in pins: pin.value = True time.sleep(0.5) for pin in pins: pin.value = False time.sleep(0.5)
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import busio import digitalio import adafruit_74hc595 spi = busio.SPI(board.SCK, MOSI=board.MOSI) latch_pin = digitalio.DigitalInOut(board.D5) sr = adafruit_74hc595.ShiftRegister74HC595(spi, latch_pin) pin1 = sr.get_pin(1) while True: pin1.value = True time.sleep(1) pin1.value = False time.sleep(1)