i want to find whether a digital pin of arduino let say digital pin#4 is "HIGH or LOW" using a voltage divider resistor.
just as "analogRead()" that the voltage sense divider network & arduino must have common ground, is it also necessary for
digitalRead() that the "HIGH/LOW" detection divider network & arduino must have same common ground?
if to consider that divider network & arduino pro mini have different ground then is it possible for pro mini to detect HIGH/LOW voltage at
4k7 resistor as in picture above.
Its error (for 201) is 5% if thats tolerable. You could do a cal routine in which
you transmit a control signal across barrier with another LED/photo coupler
and force a known current on signal origin side into LED, measure output,
and use that as a correction factor.....
It can only sense voltages between its input and ground pin so either you connect the grounds together or you employ some extra circuitry that can use two different ground references. The circuit to do that will depend entirely upon the application, there is no generic solution.
Be careful, if there is a voltage between GND1 and GND2 it could be sufficient or the wrong polarity to damage the Genuino board.
Its error (for 201) is 5% if thats tolerable. You could do a cal routine in which
you transmit a control signal across barrier with another LED/photo coupler
and force a known current on signal origin side into LED, measure output,
and use that as a correction factor.....
as suggested in post#3 for isolating grounds & transforming signal from one side to other this circuit has solved my problem
off sensing HIGH/LOW voltage at the led side. now turing the IR led of photocoupler will make the logic state HIGH/LOW in case power
is present at IR led side.
if you are detecting power good derived from a micro sending logic output
keep in mind as a micro is being powered up most have a range of supply V
where outputs are undefined. So in code you might qualify the test with
several "reads" over time, like in debouncing a push button, and if reads
satisfy the condition for those sequential reads then a legit value is established.