Abstract
The shiftOut() sends a byte of data bit by bit.
Source Code
The shiftOut() is defined in hardware/arduino/avr/cores/arduino/wiring_shift.c as below.
|
|
The inputs are dataPin, clockPin, bitOrder and val, they all are uint8_t, returns nothing.
|
|
It loops to send 8 bits of data.
|
|
When the bitOrder is LSBFIRST, this function sends data from LSB. It sends the 0th bit of val by calculating bitwise AND of val and 1. Then shifts right by 1 bit to make next bit to be the 0th bit of val.
When the bitOrder is MSBFIRST, this function sends data from MSB. It sends the 7th bit of val by calculating bitwise AND of val and 128(= 0B10000000). Then shifts left by 1 bit to make next bit to be the 7th bit of val.
It uses digitalWrite() to send data.
Finally it sends a pulse making clockPin HIGH then LOW.
|
|
Version
Arduino AVR Boards 1.8.6
Last Update
March 21, 2023