EthercatDevice_QECRXXD.digitalRead()

[EthercatDevice_QECRXXD]

説明

Read a HIGH or LOW value from a digital input pin on the EtherCAT Slave device.

Class Modules

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. */

Format

int digitalRead(uint8_t pin);

Syntax

EthercatDevice_QECR11DF0D slave;
slave.digitalRead(0);

Parameters

pin: the pin number

Returns

the value of the digital input pin on the EtherCAT Slave; if there is an error, the return value is LOW.

Example

#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);
    }
}

Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール