How can I read 49 LDRs from single pin?

Thanks a lot. But unfortunately we are really at the beginners phase. Can you explain how to and what to do ?

1 Like

Guys we have planned to use buttons instead of LDRs. But we are struggling with buttons minimum force to push. Our car is like 250-300 grams and while it is driving on the squares, the force needed to push the button will not be enough. So I came with LDR idea. But buttons were the our main technique. I am also open for different kinds of techniques other than LDR or buttons.

"Thanks a lot. But unfortunately we are really at the beginners phase. Can you explain how to and what to do ?"

Do you (plural) have any resistors?

We have 220K resistors

Those aren't practical for this application (red-red-yellow, 220k).
At any rate, if you had lower values you could do a little experiment, shorting out to Ground the resistors (at A, B, C) would change the voltage at the Analog_In pin. An LDR_On would, similarly, result a very low resistance in parallel with each resistor.
This could get unwieldy though.

Other problem we has is environmental light. We will measure it and put a minimum gate value for it. For example, room light is 200 on LDR input. We will say system to ignore lights under 300.

More reality.

What type of light? If florescent tubes, they are actually flickering at your mains frequency and will mess up any light measurements.

What's your project budget?

30-35 dollars or 300 Turkish Lira

Well it depends but mostly florescent.

You could make this circuit:


There are 16 LDR and these make a Matrix. You could make it with 49 LDR. :grinning:

It is a simple circuit which used to make LDR Touch Screen Circuits... You should probe this and you can find a lot of tutorials on YOUTUBE about how you can work with Matrix by Arduino.

You should read it: How can I connect an 8x8 matrix of LDR sensors to Arduino? - #5 by Koepel

Attach a small magnet to the bottom of the car and use 49 reed switches.

Whatever technique you use, you are going to need more than one Arduino pin. How many spare pins do you have? What are your other pins used for? There are often ways to reduce the number of pins needed for other uses, so you can free up more pins for detecting the car.

100+ Switches in a single pin of Arduino - YouTube We will use this technique

What a lode of rubbish.

The reading half’s with every extra switch you add, or would do if the resistors were actually all the same value. So the absolute maximum number of switches you can have is equal to the number of bits in the A/D converter. This, for an Arduino Uno is 12.

The only people more stupid that the maker of the video is all the idiots that say what a great idea it is. It is an old technique I have used many times but it can not be stretched to anything like 100 inputs.

Did you notice how he cheated on the construction bit of the video by pulling apart a readymade circuit and showing the video backwards?

We are using ESP32

So what? How many bits does the A/D have in that processor?

Did you mean 10, Mike?

12... 10... Who cares? You can't wire 100 switches like that.

LOL! You will learn an important thing when you try. The ability to make and upload a video to YouTube does not make you an expert in electronics. That guy proves it. A total electronics newbie. He shows that plainly by not connecting series resistors to the LEDs. 100 switches! What a fool!


Have you actually connected an LDR and resistor up and ran some code to see the output?

One thing you will notice, that unless you keep your ambient light ABSOLUTELY constant, each time you cover then uncover the LDR it will not return to exactly the value you had before.

That video used switches and resistors, which basically guaranteed some near constant responses, but still they were not stable. Suggesting 100 switches really shows the presenters lack of understanding of the principle.
LDRs will not give you anywhere near that stability.

Tom... :smiley: :+1: :coffee: :australia: