Sends data to the SPI port
|data||String or blob||
The data to write to the bus
Integer — the number of bytes written to the SPI bus
This method writes the specified data to the target SPI bus and returns the number of bytes written.
Any data arriving on CIPO (controller in, peripheral out) while writing is taking place is ignored.
After writing, COPI (controller out, peripheral in) is held at the level of the last transmitted bit.
CIPO is the signal previously referred to as MISO. COPI is the signal previously referred to as MOSI.
The following code shows you how to write to an 8-bit shift register — a 74HC595 — via SPI. Note that this implementation also uses two GPIO pins: the first, pin 8, is used for selecting the peripheral device and the second, pin 1, to reset the SPI device.