EthercatDevice_QECRXXD.digitalRead()

[EthercatDevice_QECRXXD]

描述

對 EtherCAT 從站裝置上的數位 Input 腳位讀取 HIGH 或 LOW 。

模組類別

class EthercatDevice_QECR00DC4D;  /* 12 Inputs, 4 Outputs. RJ45 power [0, 0]. With broken wire detector. */
class EthercatDevice_QECR00D4CD;  /* 4 Inputs, 12 Outputs. RJ45 power [0, 0]. With broken wire detector. */
class EthercatDevice_QECR11DF0D;  /* 16 Inputs, 0 Outputs. RJ45 power [1, 1]. With broken wire detector. */
class EthercatDevice_QECR00DF0D;  /* 16 Inputs, 0 Outputs. RJ45 power [0, 0]. With broken wire detector. */
class EthercatDevice_QECR11D88S;  /* 8 Inputs, 8 Outputs. RJ45 power [1, 1]. */
class EthercatDevice_QECR00D88D;  /* 8 Inputs, 8 Outputs. RJ45 power [0, 0]. With broken wire detector. */

格式

int digitalRead(uint8_t pin);

語法

EthercatDevice_QECR11DF0D slave;
slave.digitalRead(0);

參數

pin:腳位。

回傳

EtherCAT 從站的數位 Input 腳位的數值;如果有錯誤,則返回值為 LOW。

範例

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_QECR11D0FS slave;
EthercatDevice_QECR11DF0D slave1;

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 0;     // the number of the pushbutton pin
const int ledPin = 0;        // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup(void) {
    master.begin();
    slave.attach(0, master);
    slave1.attach(1, master);
    master.start();
}

void loop() {
    // read the state of the pushbutton value:
    bool buttonState = slave1.digitalRead(buttonPin);
  
    // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
    if (buttonState == HIGH) {
      // turn LED on:
      slave.digitalWrite(ledPin, HIGH);
    } else {
      // turn LED off:
      slave.digitalWrite(ledPin, LOW);
    }
}

函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール