CHAPTER 9

The SPI Bus

Parts You'll Need for This Chapter

Arduino Uno

USB cable (A to B for Uno)

Red LED

Yellow LED

Green LED

Blue LED

100Ω resistors (×4)

Speaker

Jumper wires

Breadboard

MCP4231 Digital SPI Potentiometer IC (×2)

CODE AND DIGITAL CONTENT FOR THIS CHAPTER

Code downloads, video, and other digital content for this chapter can be found at www.exploringarduino.com/content/ch9.

In addition, all code can be found at www.wiley.com/go/exploringarduino on the Download Code tab. The code is in the chapter 09 download and individually named according to the names throughout the chapter.

You've already learned about two important digital communication methods available to you on the Arduino: the I2C bus and the serial UART bus. In this chapter, you learn about the third digital communication method supported by the Arduino hardware: The Serial Peripheral Interface bus (or SPI bus for short).

Unlike the I2C bus, the SPI bus uses separate lines for sending and receiving data, and it employs an additional line for selecting which slave device you are talking to. This adds additional wires, but also eliminates the issue of needing different slave device addresses. SPI is generally easier to get running than I2C and can run at a faster speed. In this chapter, you use the Arduino's built-in SPI library and hardware to communicate with a digitally controllable potentiometer. You use the potentiometer to control both LED brightness and speaker volume, allowing you to make a simple ...

Get Exploring Arduino: Tools and Techniques for Engineering Wizardry now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.