Transfert the OFF/ON DC 24V as Data for mega2560

Need to transfer the detection of an on-off 24v DC voltage to Data signal (analogic or digital) to arduino mega 2560... if any idea... Sorry perhaps very simple... but i didnt find the way for dummy as me... Thanks

The simplest way would be to just use a voltage divider
But it might be better to put a buffer in between, ideally an Opto-Coupler
Here the value of the resistor is an approximation, resulting in about 7mA which depending on the Opto-coupler used might not be quite enough, if so, maybe use a 2.2K resistor instead.

1 Like


The opto is the way to go - with the resistor divider there is the possibility of back feeding the Arduino from the 24v if the Arduino is switched off .
Also any bad connection might put 24v into the Arduino and destroy it .

Another option is to use the 24v to power a relay , abs use its contacts as the Arduino input


Don't you think a PCB with screw-terminals is overkill for this application ? And does the value of R2 fall into the range required.
I see all these tiny PCB's that are being sold online, for applications where i would use just the parts.

Not if it's cheap and does the job perfectly!

And assemble them on the stripboard which you carefully planned out in advance. :sunglasses:

I would waste space and money on screw-terminals, not put a useless LED, don't waste money on a bigger box to put it in, All mounted on the same experimentation board, that either plugs into the Arduino (if it's a mega) or vice versa. (for smaller boards) It's an Opto-coupler and 1 resistor, and the one on the PCB may not even be the right one. You don't have to defend it, just because it's cheap.

The point remains - it is cheap, and it is already built as a module to simply incorporate into an overall assembly.

That is after all, what the Arduino project is all about (the bit about modules).

And the screw terminals are the most reliable connections. That's why you have "screw shields" for various Arduinos. :+1:

you are cool... thanks...
and yes I m lazy and bought a 24-5v multiple hoptocoupler...
optocoupler 24-5v

In fact it s about a 6 axes AR3 robot with a chinese limited version of Arduino board sending signal for Solenoid Gripper on 24V on-off...and i ve to connect this signal to a real arduino mega 2560 to get back this signal to control servo multiple motor... thanks

That's not cheap !

yep.... but 1.5hour to make it...(from dummy) with the risk to do it wrong... is more expensive than to buy it....if we compare the time and the cost... the lower salary is 11 euros per hour in france.

Fair enough, i thought it was a hobby. In case of a hobby, the calculation is different.

cost = fun_time_had / parts_price;

smart comment...yep

Upside down.

I think you mean "joy" - the inverse of "cost".

just ThX.... it works....

1 Like

So that optocoupler board is in there somewhere?

yes... on connecting box... thx again....
my difficulties now is to understand if i can make a feed back on robot in real time... because it s a tricky chinese arduino board.. but it s my problem...