# need to compare to LDR with a AD623 connected to an arduino

#### bend94

Joined Feb 15, 2016
46
Hi,

I need to compare two LDR value with a AD623.
The ouput of the AD623 will be connected to an arduino

Since the output voltage could be negative, how to manage that with arduino ?.

thx

#### ericgibbs

Joined Jan 29, 2010
18,007
hi bend,
Do you have a circuit to post, so that we can help.?
E

#### MrChips

Joined Oct 2, 2009
29,217
The output voltage does not have to be negative.
It depends on the configuration of the circuit.

#### bend94

Joined Feb 15, 2016
46
hi
somethink like this , in order to find which ldr has more light

#### Attachments

• 47.6 KB Views: 10

#### ericgibbs

Joined Jan 29, 2010
18,007
hi bend,
Have you considered applying a +V to Vref, this would result in positive output voltages.
Make the calculations in the Arduino.
E

@bend94
BTW: what are the resistance ranges of the LDR's you are using.?

#### sghioto

Joined Dec 31, 2017
4,917
Why use the opamp, the Arduino has comparator inputs.

#### bend94

Joined Feb 15, 2016
46
I want to compare the value of the 2 LDR. with the arduino

if i am right:
1/ i plan to put REF and -VS to gnd (same gnd as the arduino)
2/ i plan to put +VS to 5V

you mean AD623 output will be always positive ?

1/ what will be the AD623 output voltage if R1>R2 ?
2/ what will be the AD623 output voltage if R2>R1?
3/ what will be the AD623 output voltage if R2=R1

thx

#### bend94

Joined Feb 15, 2016
46
Why use the opamp, the Arduino has comparator inputs.
i was not aware of that, please explain

#### ericgibbs

Joined Jan 29, 2010
18,007
Hi bend,
Looking over your circuit, it will give you problems.
Post a circuit with component values and voltages In and Out.
We also need the LDR specification and the expected light range.
E

#### sghioto

Joined Dec 31, 2017
4,917
i was not aware of that, please explain
Just one of the Arduino features. You will need to look over the Arduino manual or check out some tutorials on line.
It might be more complicated then you want depending on what the outcome of the LDR is supposed to do.

#### Ian0

Joined Aug 7, 2020
8,386
hi
somethink like this , in order to find which ldr has more light
That's not how you use an instrumentation amplifier.
See figure 71 of the datasheet
A single resistor should go between the two Rg terminals.

If you just want to compare two light levels, connect the two LDRs to two comparator inputs on the Arduino. Add a pullup resistor to V+ on each, choose the pullup resistor to be approximately equal to the LDR resistance at the centre of the range over which you are going to measure.

Or if you want to use an external component to compare two values use a comparator. (such as LM393) The instrumentation amplifier is fifty times the price.

#### bend94

Joined Feb 15, 2016
46
thx

#### MrChips

Joined Oct 2, 2009
29,217
Simple. Put the two LDRs in series to make a voltage divider.

Or use a bridge circuit.

#### Ian0

Joined Aug 7, 2020
8,386
The requirement is that it uses an arduino.
So the two LDRs in series will be a worthwhile improvement, provided that the comparator in the arduino can be programmed for Vdd/2 as its reference (I don't know enough about arduinos, but the processors I use can)
The second circuit would imply that points 1 and 2 be connected to the arduino's comparator (which is what I suggested) Ra and R1 being pullup resistors and Rx and R2 being LDRs or alternatively Rx and Rx being LDRs and R1 and R2 being two equal value resistors.
(By the way, LDRs are illegal under RoHS regulations)

#### ericgibbs

Joined Jan 29, 2010
18,007
hi @bend94
Is this project a Homework or College assignment.?

Moderation

#### Poyntat

Joined May 24, 2022
60
Why can’t @bend94 connect the two LDRs to the same fixed voltage (Vcc) via suitable resistors and measure the voltage at the resistor, LDR junction using separate Arduino adc channels.
These values can then be compared and actioned as necessary.

#### Ian0

Joined Aug 7, 2020
8,386
Why can’t @bend94 connect the two LDRs to the same fixed voltage (Vcc) via suitable resistors and measure the voltage at the resistor, LDR junction using separate Arduino adc channels.
These values can then be compared and actioned as necessary.
He could, but he only wanted to compare them, and for that task a comparator would be more appropriate.

#### MrChips

Joined Oct 2, 2009
29,217
Why can’t @bend94 connect the two LDRs to the same fixed voltage (Vcc) via suitable resistors and measure the voltage at the resistor, LDR junction using separate Arduino adc channels.
These values can then be compared and actioned as necessary.
That is a possible solution. Since TS is only interested in which LDR receives more light (as in a line or source tracking robot) a simple digital output from an analog comparator would do.