chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko


  1. Synopsis

  2. Description

  3. Return Value

  4. Conforming To

  5. Examples

  6. See Also


 uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) 


shiftIn() utilises a pair of I/O pins to create a half-duplex synchronous serial interface. clockPin is toggled repeatedly and each time it goes HIGH the dataPin is sampled as one bit of a byte. That bit is added to the output value which is shifted either left or right to accommodate it. The parameter bitOrder indicates in which direction the shift should occur and to which end of the byte the incoming bit should be added. Possible values for bitOrder are MSBFIRST or LSBFIRST.

Eight bits are received in this manner before the function returns the value that has been received.

This functionality works akin to the receiving portion of a master SPI interface.

Return Value

The received byte.

Conforming To

shiftIn() conforms to the Arduino 1.6.x API.


 uint8_t val = shiftIn(3, 4, MSBFIRST);

See Also

digitalRead(), digitalWrite(), getPinMode(), pinMode(), pulseIn(), shiftOut()