I want to read the output of a PLC with an Arduino. If the PLC sends a HIGH (5 V) on a OUTPIN, the Arduino should read this HIGH, else LOW. I am generally using this code for this:
pinMode(button1, INPUT_PULLUP);
This way I can only read if the input of Arduino becomes GND, otherwise the Arduino reads every time as HIGH. This is what I want.
But this time the input is only 5 V from the PLC. How to read the 5 V input correctly? If I don't use a pull-up, the Arduino reads absurd values. Like this:
pinMode(button1, INPUT);
How can I read a 5 V input state correctly with an Arduino? I don't want to use an additional resistor or something else.