0

74HC595 library and RPi Pico
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

74HC595 library and RPi Pico

by cheeseshark on Wed Oct 13, 2021 9:26 pm

Is there any documentation out there that explains the use of the adafruit_74HC595 library with the Raspberry Pi Pico with Circuitpython?

The existing example on this site use board references that don't exist on the Pico (board.SPI).

Code: Select all | TOGGLE FULL SIZE
import time
import board
import digitalio
import adafruit_74hc595

latch_pin = digitalio.DigitalInOut(board.D5)
sr = adafruit_74hc595.ShiftRegister74HC595(board.SPI(), latch_pin)


Thanks in advance

Mike

cheeseshark
 
Posts: 4
Joined: Sun Sep 26, 2021 3:43 pm

Re: 74HC595 library and RPi Pico

by kattni on Thu Oct 14, 2021 1:47 pm

Hello Mike,

board.SPI() is a board-specific object available in the board module for many CircuitPython boards. It takes the place of using busio and providing it a clock pin and data pin.

To use it on the Pico with SPI, you would do the following along with the rest of your code, replacing clock_pin and data_pin with the pins you connected to on the Pico.
Code: Select all | TOGGLE FULL SIZE
import board
import busio

spi = busio.SPI(board.clock_pin, board.data_pin)

Here is an example of what it might look like:
Code: Select all | TOGGLE FULL SIZE
import board
import busio

spi = busio.SPI(clock=board.GP2, MOSI=board.GP3, MISO=board.GP4)

Then, you change the current example's board.SPI() to be the spi object created above, and it should work.

Hopefully this helps.

kattni
 
Posts: 121
Joined: Fri Aug 18, 2017 6:33 pm

Re: 74HC595 library and RPi Pico

by cheeseshark on Thu Oct 14, 2021 4:34 pm

Thanks for the information. I'll give it a try when I get home.

cheeseshark
 
Posts: 4
Joined: Sun Sep 26, 2021 3:43 pm

Please be positive and constructive with your questions and comments.