How to read a digital Input

How to read a digital Input

You can read the data of a Digital Input through:

...
int myDigital;
...
void setup() {
   pinMode (5,INPUT);
}

void loop() {
   myDigital = digitalRead(5);
}

With this piece of code you’ll read the voltage of a PLC pin. As our digital input works between 0-24V, the read value (myDigital) will be a value: 0 or ~24V.
 
Note: The example pin “5”, is only an example. You need to check in your PLC which pin to use for reading, writing, or reading and writing. Only if your PLC is able to work as a digital input, then, you can send this code into it.

Comments are closed.