write()

描述

将 86Duino 编码器计数器设定为指定值。此函式只可用于 Pulse/DIR、CW/CCW、A/B Pulse 工作模式。

语法


Enc0.write(number)
Enc1.write(number)
Enc2.write(number)
Enc3.write(number)

参数

Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。

number:指定给编码器计数器的值。(unsigned long 型别)

回传

无回传值

范例

#include <Encoder.h>

void setup() {
  Serial.begin(9600);
  Enc0.begin(MODE_AB_PHASE);
  Enc0.write(200L); // 将计数器设定成从 200 开始计数
}

void loop() {
  Serial.println(Enc0.read());
  delay(100);
}

See also

read()


函式库参考主页面

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