How can I read 49 LDRs from single pin?

We are making a project. We have 49 interactive squares. And we have a toy car. We want to drive the car on these 49 squares. And we need to determine where the car is at all time. I came with an idea that relies on LDRs photoresistors. Each square will have 1 LDR, 49 LDRs in total. Car will have a high power light source underneath. Squares are going from 1 to 49 ID'ed each. When car comes upon a square it will light up the LDR. So we will know where the car is. On 26th square or 17th or 42nd. Our problem is to read all these LDRs from a single pin. As we need other parts such as LED screen, other buttons to control the system etc. Are there a way to do that ? If not, can you have an other suggestions how to find the car all the time?

At least three of these:

But do realise you will need a number of pins to select which LDR to read at any one time.

Why this fuss about a single pin on your Nano? :face_with_raised_eyebrow:

Do you know about capacitive screens? Maybe you can do this matrix circuit, but in this case you need to replace the capacitors for LDRs. With this you can work with a LDR Matrix and it has to be connect in your analog pins.
You need this circuit:


then, you can work with a matrix into your program.

This approach is similar to reading pushbuttons with Analog_In.
I'm only showing 3, you'll need 46 more - it's a lot of wiring. And you'll have to experiment with values, take data.

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?