LM358 Comparator as Arduino digital Input

I'm currently working on a book page indicator project. I'm using a photoresistor/LDR as the book page indicator, which will be exposed to light from each opened page. Since there are 10 pages in the book, the analog pins on the Arduino are insufficient. So, I thought of using an LM358 as a brightness level comparator sensor for the LDR, and this is the circuit I've created.

*Im using 10K Trimpot.

before connecting to arduino pins, i used 330 Ohm resistor and LED light on each LM358 output on the project board to see if there're any Outputs. I've tried the circuit on a project board and here's what I've found:

  1. The output from each LM358 is only 3.3V even though the IC were supplied with 5V.
  2. The LDRs used have varying sensitivities; some sensors are more sensitive than others.
  3. The circuit is quite janky when tested, perhaps because I used dupont jumpers.
  4. When the sensors exposed light while under the page's paper, some sensor were Outputing High Voltage.

I'm seeking help and advice for my project:

  1. Would it be better if I change the negative input (reference voltage) on the LM358 connected to the LDR and the positive input (comparison input) to the trimpot so that when light enters, the LM358 output becomes LOW, activating the input pin on the Arduino as Active Low?

  2. Or should I connect a NPN transistor to each LM358 output, so when the LM358 output is High, it activates the NPN transistor, connecting 5V supplied emitter and collector to the Arduino digital input pin, making it Active High? If so, which transistor is suitable considering the LM358 output is only 3.3V?

Sorry if my english is hard to understand, since i'm not english native speaker dan still learning.

You can put an external multiplexer, like a CD4051, in front of any of the arduino analog pins to get an additional 8 (actually 7, since it uses one analog pin) inputs.

Use a TLV3702 voltage comparator and all your problems will be solved.
However it will not drive and LED.
Do you actually need the LEDs?

Thank you for your suggestion, it looks like an interesting component but unfortunately nobody sell those IC in my country. I cant buy from international shop since the cost of shipping is expensive, and the Customs is very problematic.

Thank you for your suggestion. This is a new method i just found out. I'll check on it and give updates !

How about MCP6542 or MCP6544

Same situation :face_exhaling:

I know you can get the LM393 or LM339. However you will need a power supply of a at least 7V but less than 30V for those comparators. They also need a pullup resistor on the output but they can be used with LEDs

Consider the LM2901 Comparator. The LM358 is an amplifier and has limited output voltage.
You should add some hysteresis for any approach.

The LM2901 is an open collector output and therefore requires a pullup resistor.

10 LDRs
5 10K resistors
5 analog pins
2 digital pins
No pots
No comparators
That's all... I think. Not tested it.

I guess @PaulRB suggests that you do not need an analog input to read an ldr...
You can use a digital input as long as you make a clever choice of your resistors...

No, but I'm suggesting you might not need one analog pin per LDR if arranged as a matrix. But wondering if some diodes may also be needed...

Basely the circuit looks OK. The LM358 is an old but good op amp. Please realize it is not a rail to rail output. Try a pull up resistor on the output, that may work. It works for me on some op amps and not others.

You need bypass capacitors, Analog is very sensitive to that. You can add a resistor from the output to the +input adding hysteresis. Start at about 500K,

@Koepel simulated the matrix idea here, it seems to work ok. For @ridwananhar 's project it can be a 5x2 matrix.

Sounds like a good idea!

It's just a less common variant of the LM339 that I suggested. Still needs a power supply >7V

If you use the LM2901 you will need a pull up resistor as it is an open collector output. I used it over 40 years ago, it is an old but reliable part.

[smh]

I still say that instead of these large numbers of components -- comparators, capacitors, reference resistors, etc., that this is far easier with a single 50-cent multiplexer on A0. Heck, a couple of external I2C ADCs would be less work than wiring up all those parts.

Gotta say that I like @PaulRB 's suggestion of matrixing the analog inputs tho. Intriguing.

I may have not looked at newer versions of the LM339 however looking again I see there are low voltage versions of the LM339 and LM2901.

I'm sure with a little more investigation there are other low voltage (and likely lower current) comparators.

What are the part numbers?
Or did you mean a low voltage version of the 358 which would be the LMV358?