Skip to Content
Circuitera

Trace the byte received during an Arduino SPI transfer

SPI clocks transmit and receive bits during the same exchange.

0 of 3 complete · Progress saved on this device

Work out the example

SPI clocks transmit and receive bits during the same exchange. A device can need a command byte first and provide its response during a following transfer. A dummy outgoing byte can supply those clocks.

How many clocks do two eight-bit exchanges require?

Decide what to check next

The correct command, timing and dummy value depend on the peripheral. The exercise counts bytes and clocks only. A physical device’s returned byte requires a matching peripheral and datasheet.

Compare with the serial result

The trace prints 16, 55 and 0. It illustrates a schedule rather than addressing a physical peripheral.

Open the exact Uno example

The trace prints 16, 55 and 0. It illustrates a schedule rather than addressing a physical peripheral.

void setup() {
  Serial.begin(9600);
  const byte command=0x55, dummy=0;
  const byte count=2;
  Serial.println(count*8);
  Serial.println(command, HEX);
  Serial.println(dummy, HEX);
}
void loop() {}

Verified with [email protected] on Uno R3 (2026-12-05 UTC). This check did not use physical hardware.

Continue learning

Sources