Can I make 10 Analog inputs out of the default 6?

Hello,

I’m working on my project, where i need to use 10 LDR sensors that would mean each one is representing numbers from 1 to 10 (1 number- 1 LDR), that will be shown on display.

My question is, how to read all 10 LDR’s, when on my Arduino UNO are only 6 Analog Inputs.

Thanks for any suggestions, I’m new to Arduino world and I can’t find any answer on internet.

There was discussion recently about putting ldrs on digital pins, with the pullups enabled to make a divider.

(Can't find the thread, or the sketch in which I tested it, but it worked for me.)

Do a Google search for 'analog multiplexer'.

Here's a quote and some test code from the thread I mentioned and then found:

groundFungus:
I have experience using LDRs with Arduino. An LDR must be part of a voltage divider. I usually enable the internal pullup resistor on a pin and wire the LDR from that pin to ground. The pin will read HIGH (1) in the dark and LOW (0) when lighted. If you need to change the sensitivity, use an external resistor from the pin to Vcc and do not enable the internal pullup.

Test code for Mega with LDR to pin 12 and ground.

const byte sensorPin = 12;
boolean sensorState;

void setup()
{
   Serial.begin(9600);
   pinMode(sensorPin, INPUT_PULLUP);  // comment out if using external pullup resistor
}

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 500;
   if (millis() - timer >= interval)
   {
      sensorState = digitalRead(sensorPin);
      Serial.println(sensorState);
   }
}

You can measure light levels simply and very quickly using a digital port, by using an LDR to charge a capacitor. This can be much faster than using the ADC.

If you start from a discharged capacitor, the time to charge (input port LOW to HIGH transition) is directly related to the LDR resistance. Pololu uses this method for their QTR sensors on line following robots.

mikb55:
Do a Google search for 'analog multiplexer'.

5pcs adc cmos cd74hc4067 16ch channel analog digital multiplexer module board sensor controller Sale - Banggood.com-arrival notice-arrival notice

Is this it? and how do I write the setup code?

Something like this useful? SparkFun Analog/Digital MUX Breakout - CD74HC4067 - BOB-09056 - SparkFun Electronics

jremington:
You can measure light levels simply and very quickly using a digital port, by using an LDR to charge a capacitor. This can be much faster than using the ADC.

With an ADC reading taking just over 100 us I don't think it's going to be that much faster, and it's at a cost of serious code overhead.

If it's just for light/dark measurement (as suggested in the OP) I'd pair them with a suitable resistor (value to be determined experimentally; it depends on the actual light levels involved) and use a digital input.