Chapter 9

The SPI Bus

Chapter Summary

This chapter covered the following concepts:

  • The SPI bus uses two data lines, a clock line, and a slave select line. An additional slave select line is added for each slave device, but the other three lines are shared on the bus.
  • The Arduino SPI library can be used to facilitate easy communication between the Arduino and slave devices.
  • You can talk to multiple SPI devices over the same bus lines by using multiple SS pins.
  • You can control SPI potentiometers using the Arduino Library.
  • You learned how to dive deeper into understanding and working with datasheets.
  • You learned how to simultaneously adjust speaker volume and frequency using the tone library paired with an SPI digital potentiometer.


If you’re unable to obtain the MCP4231 Digital SPI potentiometer in your country, you can also use the MCP4151 and leave the MISO line disconnected.

Parts List

Useful Links

Color Wiring Diagrams


Follow along with this video for a visual tutorial about the SPI Bus:

Watch a demo of the SPI digital potentiometer color adjuster created in the chapter:

Watch a demo of the audiovisual platform created in the chapter:


Chapter 9 Code Download

All code is licensed via the GNU GPL v3. Code is maintained and updated on GitHub. The download zip linked above always contains the most recent version of the code examples that have been pushed to the GitHub Code Repository.

Taking it Further

Use SPI devices to enable all kinds of exciting new projects:

  • Add digital accelerometers and gyroscopes as sensors to your project.
  • Utilize an SPI high-precision analog-to-digital converter to read analog signals with a higher degree of resolution than the Arduino can do on its own.
  • Add an SPI thermocouple chip to facilitate super-accurate temperature measurements.
  • Use the audiovisual platform developed in this chapter to build interactive art exhibits with lights and sounds.

References & Credits

  • Figure 9-2: MCP4231 Pin-Out Diagram Credit: © 2013 Microchip Technology Inc. (source, PDF)
  • Figure 9-3: MCP4231 AC/DC Characteristics Table Credit: © 2013 Microchip Technology Inc. (source, PDF)
  • Figure 9-4: MCP4231 SPI Command Format Table Credit: © 2013 Microchip Technology Inc. (source, PDF)