from machine import Pin from time import sleep, sleep_ms, sleep_us spi = SPI(1, baudrate=10_000_000, polarity=0, phase=0, bits=8, sck=10, mosi=11, miso=12) Button = Pin(20, Pin.IN, Pin.PULL_UP) LATCH = Pin(13, Pin.OUT) def LS165(): LATCH.value(1) sleep_us(1) LATCH.value(0) sleep_us(1) LATCH.value(1) # data is latched - now shift it in rxdata = spi.read(2, 0x42) return(rxdata) while(1): Y = LS165() print(Y) sleep(0.1)