All tutorials

4 · Displays & buses

Understanding the SPI bus

Advanced20 min

Goal

Exchange a byte as SPI master and observe the 4 wires.

Why it matters

MOSI, MISO, SCK, CS: SPI is full-duplex, unlike I²C.

Steps

  1. 01Add an SPI peripheral (TFT or SD card).
  2. 02SPI.begin() inside setup(), CS as OUTPUT.
  3. 03Pull CS low, send SPI.transfer(0x9F), raise CS.
  4. 04Print the answer in hexadecimal.

This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.

Next tutorials