Simulating a PLC ladder diagram on arduino

A set or reset is easiest done with an if without else.

I1 = digitalRead(Input1);
I2 = digitalRead(Input2);
I3 = digitalRead(Input3);

if (I1 && !I2) Q1 = 1;
if (!I3) Q1 = 0;

digitalWrite(Q1, Output1);

If you want to simulate a plc, remember to first read all your inputs, then do your networks and in the end write your outputs...

1 Like