Simulating a PLC ladder diagram on arduino

Zatalian thanks for the code. it works but theres a slight Typo in the code
int the part

digitalWrite(Output1, Q3);

it should have been

digitalWrite (Q3, Output1);

there's only one problem with this function of the one i post before,
if let say that i would like to call keep function a couple of time,
any term that use the same term will exhibit the same result.