shiftIn()

描述

以 byte 为单位来接收资料,一次一个 bit。可以从最高或者最低有效位元开始接收资料;接收每一个 bit 的过程中,时脉 pin 脚会先被拉成高电位,然后从资料 pin 上读取一个 bit,再将时脉 pin 脚拉成低电位。

注意:如果你使用的装置是属于正缘触发的类型,你需要确定时脉 pin 脚在呼叫 shiftOut() 之前是处于低电位的状态,例:可以呼叫 digitalWrite(clockPin, LOW) 将 pin 脚设定为低电位

这个函式是以软体模拟方式实作的,可以参考 SPI 函式库,它提供了一个高效的硬体实作方式,但只能作用在某些固定的 pin 脚上。

语法


byte incoming = shiftIn(dataPin, clockPin, bitOrder)

参数

dataPin: 要读取 bit 的 pin 脚 (int)
clockPin: 要输出时脉的 pin 脚 (int)

bitOrder: 读取 bit 的顺序,不是 MSBFIRST 就是 LSBFIRST (从最高或最低有效位元开始读取)

回传

读取到的数值 (byte)

See also

shiftIn()
SPI


语法参考主页面

本页由热血青年 LBU 译自英文版。

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.