writeSPI()

[Serial Peripheral Interface]
bool writeSPI(unsigned char data);

Description

Writes data to the SPI bus and sends it through the data out line.

Parameters

data: the data to be sent through the data out line.

Returns

A boolean value that indicates if the data was successfully sent.

Example Code

The code initializes the SPI communication with the clock pin connected to pin 13, the data in pin connected to pin 12, the data out pin connected to pin 11, the chip select pin connected to pin 10, and the polarity of the chip select line set to LOW.

Continuously checks if the chip is selected, and if it is, it sends data to the leader chip.

void setup() {
    beginSPI(13, 12, 11, 10, LOW);  // initializes the SPI communication with the clock pin connected to pin 13, the data in pin connected to pin 12, the data out pin connected to pin 11, the chip select pin connected to pin 10, and the polarity of the chip select line set to LOW
}

void loop() {
    if (selectedSPI()) {  // checks if the chip is selected
        writeSPI(0x01);   // sends data to the leader chip
    }
}

Notes and Warnings

The data parameter must be an 8-bit value or an unsigned char type.