Controlling shift registers via SPI

Hack a Day’s very own (and very prolific contributor) [Mike Szczys] put up a great tutorial on how to drive shift registers with an SPI interface.

[Mike]‘s earlier tutorial of the 595 shift register goes through the functions of a shift register pin by pin. In a 595, bits for each position in the register are sent over one at a time. Most microprocessors have an Serial Peripheral Interface, and using an SPI bus means a lot less mucking about.

An ATmega168 was used for this build, although most Atmel chips can be made to work as an SPI master device. There are just three wires connecting the microcontroller to the shift register – SER, SRCLK, and RCLK. Like any other shift register setup, the build can be expanded by connecting the QH’ pin of the first 595 to the SER pin of the second.

[Mike] graciously made all the code for his build available. The video after the break is a 16-bit binary counter, a good stopping point before [Mike] rebuilds his Larson scanner/Cylon/Kitt, moving away from a PWM-based build to a register-based one.


  1. Alan Kilian says:

    Some friends and I built an art project using 196 shift registers to drive 343 stepper motors.

    It lived in the Science Museum of MN and the Exploratorium for a while:

  2. PJ Allen says:

    Building up the suspense to E5F… you leave the audience on the edges of their seats… Masterful! (:

  3. Stefan says:

    Isn’t that kind of the definition of SPI? Controlling arbitrary devices as shift registers?

    • BrainSlugs83 says:

      Usually there’s some kind of addressing that goes on and a shared data line, no? I assume this tutorial walks you thru all that but I haven’t looked. Maybe there’s a dedicated /E per device in SPI. *shrug*

      *unshrug* dammit, now I have to look.

    • BrainSlugs83 says:

      Hmm… there seem to be a lot of issues with driving color displays (VGA and/or Composite) with these guys — I wonder with 2 or 3 595s and 3 (5 or 8 bit) R2R ladders if higher res vga (or other software generated video signals) could be realized. — Is the SPI faster than the core execution speed? (I think AVR can get 1 MIPS per 1 MHz… so the answer is probably no…)

  4. Quwat says:

    What kind of speed does this pull compared to direct port access?

  5. WatchAvex says:

    In my opinion you are not right. Write to me in PM, we will talk.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 96,467 other followers