> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/arduino-language/functions/advanced-i-o/shiftout-datapin-clockpin-bitorder-value.md).

# shiftOut(dataPin, clockPin, bitOrder, value)

### 参数

| 参数名      | 描述                          |
| -------- | --------------------------- |
| dataPin  | 输出每一位数据的引脚(int)             |
| clockPin | 时钟脚，当dataPin有值时此引脚电平变化(int) |
| bitOrder | 输出位的顺序，最高位优先或最低位优先          |
| value    | 要移位输出的数据(byte)              |

### 注意

dataPin和clockPin要用pinMode()配置为输出。 shiftOut目前只能输出1个字节（8位），所以如果输出值大于255需要分两步。

```c
//最高有效位优先串行输出int 数据= 500;
//移位输出高字节s
hiftOut(dataPin, clock, MSBFIRST, (data >> 8));  
//移位输出低字节
shiftOut(data, clock, MSBFIRST, data);
//最低有效位优先串行输出data = 500;
//移位输出低字节
shiftOut(dataPin, clock, LSBFIRST, data);  
//移位输出高字节
shiftOut(dataPin, clock, LSBFIRST, (data >> 8));
```

### 例子

相应电路，查看tutorial on controlling a 74HC595 shift register

```c
// ************************************************ ************** ////  Name    : shiftOut代码, Hello World                         ////  Author  : Carlyn Maw,Tom Igoe                               ////  Date    : 25 Oct, 2006                                      ////  版本 : 1.0                                               ////  注释：使用74HC595移位寄存器从0到255计数         ////// ************************************************ ****************//引脚连接到74HC595的ST_CPint latchPin = 8;//引脚连接到74HC595的SH_CPint clockPin = 12;//引脚连接到74HC595的DSint dataPin = 11;void setup() {//设置引脚为输出  pinMode(latchPin, OUTPUT);  pinMode(clockPin, OUTPUT);  pinMode(dataPin, OUTPUT);}void loop() {  //向上计数程序   （J = 0; J <256; J + +）{     //传输数据的时候将latchPin拉低digitalWrite(latchpin, LOW);     shiftOut的 （dataPin，clockPin，LSBFIRST，J）;    //之后将latchPin拉高以告诉芯片     //它不需要再接受信息了digitalWrite(latchpin, HIGH);     delay(1000);}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ubtechedu.gitbook.io/chinese/arduino-language/functions/advanced-i-o/shiftout-datapin-clockpin-bitorder-value.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
