Skip to content

This project demonstrates basic SPI (Serial Peripheral Interface) communication using an Arduino UNO as the Master device. It sends a sequence of 8-bit data values (0x80 → 0x01) through the SPI bus — a useful experiment for testing data shifting, LED control through SPI, or communication with SPI-based peripherals.

Notifications You must be signed in to change notification settings

asathiskumar98-byte/Arduino-SPI-Communication-Data-Transfer-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔄 Arduino SPI Communication – Data Transfer Example 📘 Overview

This project demonstrates basic SPI (Serial Peripheral Interface) communication using an Arduino UNO as the Master device. It sends a sequence of 8-bit data values (0x80 → 0x01) through the SPI bus — a useful experiment for testing data shifting, LED control through SPI, or communication with SPI-based peripherals (like shift registers, DACs, or displays).

🧩 Components Required

Arduino UNO

SPI-compatible slave device (e.g., 74HC595 shift register, DAC, or another Arduino)

Jumper wires

Breadboard

⚙️ Pin Connections (Arduino as SPI Master) Arduino UNO SPI Function Description Pin 10 SS (Slave Select) Used to enable/disable slave Pin 11 MOSI Master Out, Slave In Pin 12 MISO Master In, Slave Out Pin 13 SCK Serial Clock

Note: Connect GND of Master and Slave together. The MISO pin isn’t used in this demo since the Master only transmits.

💻 Arduino Code

#include <SPI.h>

void setup()
{
  pinMode(10, OUTPUT);  // SS pin
  SPI.begin();          // Initialize SPI as Master
  delay(100);
}

void loop()
{
  // Send 8 data bytes in sequence
  digitalWrite(10, LOW);
  SPI.transfer(0x80);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x40);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x20);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x10);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x08);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x04);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x02);
  digitalWrite(10, HIGH);
  delay(100);

  digitalWrite(10, LOW);
  SPI.transfer(0x01);
  digitalWrite(10, HIGH);
  delay(100);
}

📊 Explanation

The SPI.transfer() function sends one byte (8 bits) at a time via MOSI.

The Slave Select (SS) pin is toggled LOW before transmission and HIGH afterward to indicate the start and end of a frame.

Each data byte represents a bit pattern, commonly used for LED shifting or register-based control.

Example:

0x80 → 10000000

0x40 → 01000000

...

0x01 → 00000001

🚀 Applications

Testing SPI signal timing and logic analyzer readings

Driving shift registers (e.g., 74HC595)

Sending data to DAC/ADC chips

Learning basic SPI protocol behavior

🧭 Future Enhancements

Add SPI Slave Arduino to verify bidirectional data exchange.

Implement multi-byte transfers and chip-select multiplexing.

Combine with LCD/LED display modules to visualize data.

About

This project demonstrates basic SPI (Serial Peripheral Interface) communication using an Arduino UNO as the Master device. It sends a sequence of 8-bit data values (0x80 → 0x01) through the SPI bus — a useful experiment for testing data shifting, LED control through SPI, or communication with SPI-based peripherals.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages