11The SPI Bus and Third-Party Libraries

Parts You'll Need for This Chapter

  • Arduino Uno or Adafruit METRO 328
  • USB cable (Type A to B for Uno, Type A to Micro-B for METRO)
  • Half-size or full-size breadboard
  • Assorted jumper wires
  • 220Ω resistors (×4)
  • 5mm common-anode RGB LED
  • Piezo buzzer
  • Adafruit LIS3DH breakout board

You've already learned about two important digital communication methods that are available to you on the Arduino: the I2C bus and the serial UART bus. In this chapter, you will learn about a third digital communication method supported by the Arduino hardware: the Serial Peripheral Interface bus, or SPI (often pronounced “spy”) 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 extra wires, but also eliminates the problem of needing different slave device addresses. The SPI bus is generally easier to get running than I2C and can run at a faster speed. In this chapter, you will learn about using the Arduino's built-in SPI hardware to communicate with a digital accelerometer. You will learn how to find and install third-party libraries that ...

Get Exploring Arduino, 2nd Edition 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.