# Using a voltage divider and an N-channel MOSFET to switch an Arduino input pin from a EL2008 Beckhoff digital output module

I need to switch an Arduino input pin (0-5 V, max current is 40 mA) from an EL2008 Beckhoff digital output module (+24 V HIGH, 0V LOW, max output current of 0.5 A) using the circuit depicted below. I have not tested the circuit outside of simulations.

Would it work as desired?

That is, if I connect the source to the Arduino's pin would it

1. Switch the pin
2. Not damage the Arduino
3. Will the resistors burn up from the power being dissipated?

Please note: I am using Vcc from the Arduino as the drain-to-source voltage. Additionally, I've used a battery of 24 V and 48 ohm internal resistance to mimic the HIGH state (@ 0.5 A) of the EL2008 Beckhoff module.

• N-Channel MOSFET: IRL520N
• Resistors: 1.5K Ohm and 390 Ohm (both 1/4 W)

• It won't work. As it is connected now, P23 is always connected to GND. If you use the nMOSFET you need to change D1 into a resistor and connect the drain to P23. Or use a pMOSFET, get rid of the diode and connect a resistor between source and GND. Connect P23 to the source. – Swedgin Feb 19 at 10:00
• Should D23 be above the MOSFET? – GRANDMAST3R5 Feb 19 at 10:04
• As for the power dissipated: P = UI = U * U / R so that's 0.3W. I'd use resistors of an order x1000 bigger. – Swedgin Feb 19 at 10:04
• Depends on the mosfet. Trace your line now, it goes directly to the negative pole of the your 24V source. – Swedgin Feb 19 at 10:05
• I'm using an N-channel, therefore current travels into drain and out of source, correct? If I put the Vout of the D23 pin above the MOSFET, it should travel into the pin, correct? – GRANDMAST3R5 Feb 19 at 10:10