LDR Multiplexing

Let us see the bottom of the Mux PCB.

Headers need to be soldered to the PCB.

The shorter header pin goes through the MUX PCB from the bottom of the MUX PCB and then soldered from the component side.

The longer header pin plugs into the solder-less breadboard.


The other option is your header pins may be quite long hence they can plug into the breadboard ‘and’ you can also plug female connector wires from the top side of the PCB.

However we need to see the bottom of the MUX PCB.

So I have to solder the short parts that are on the pcb side and plug the longer part into the breadboard? like in the attached pictures?

Yes

Yes, it's just one of those interesting principles of electronics that you have to actually connect the parts together, just pointing one part at another does not work. :astonished:

Had I looked at this thread earlier (but I was asleep :grinning: ) I do hope I wodul have noticed the obvious problem as it happens so regularly on these forums.

While the photos are pretty good, I just can't determine the values of the resistors. What are they?

You don't need a resistor on every LDR, you just use one resistor on the multiplexer common. And if you connect the LDRs to ground rather than Vcc - 5 V - you can just use the internal pullup on the Arduino by setting pinMode for that pin as INPUT_PULLUP to provide an approximately 47k pullup - if that suits.

The idea of reading each LDR twice is that if the input impedance is very high, the first reading allows the voltage to stabilise after you switch the multiplexer to it, you ignore that first reading and reading it again will give you a more stable value.

“ Had I looked at this thread earlier (but I was asleep :grinning: ) I do hope . . . “

Give us your phone number, we'll call as needed. :wink:

Okay thank you so much!!! I soldered and tried again. It seems to work!! I added 4 more ldrs too. Only problem is that the last ldr seems to always give a high value regardless of the light intensity. Could there be any reason for it?

"You don't need a resistor on every LDR, you just use one resistor on the multiplexer common. And if you connect the LDRs to ground rather than Vcc - 5 V - you can just use the internal pullup on the Arduino by setting pinMode for that pin as INPUT_PULLUP to provide an approximately 47k pullup - if that suits.

The idea of reading each LDR twice is that if the input impedance is very high, the first reading allows the voltage to stabilise after you switch the multiplexer to it, you ignore that first reading and reading it again will give you a more stable value."

Okay this is a bit confusing to me haha.. I am sorry, I am very new to electronics and learning as I go. If I use one resistor, which LDR gets it, or is it in the circuit itself?

The resistor value is 10k.

Thank youu really!! Very much appreciated

The 10k would go from the Z pin to GND. The LDRs would be between a MUX pin and Vcc.

But the way you have it works too and might be best, the resistor to GND can be used to calibrate readings if need be; lots of options in electronics.


Did you make appropriate changes to the code ?


Always show the ‘current actual’ wiring and ‘current’ sketch when asking questions.

Just tried 12 ldrs. Here are the serial monitor values and the code below. One screenshot shows the values without any light source vs light source close to channel 0. There are certain channels that show high values regardless.

Also yes can give number if easier. Sorry for asking too many questions :))

const byte sensePin = A0;


void setup()
{
  DDRB = 255;
  Serial.begin(9600);
}

void loop()
{
  int valY [12];

  for (byte i = 0; i < 12; i++) {
    PORTB = i;
    (void)analogRead(sensePin); // discard the first reading
    valY [i] = analogRead(sensePin);
  }

  for (byte i = 0; i < 12; i++) {
    Serial.print(F("Channel"));
    Serial.print (i);
    Serial.print(F(" = "));
    Serial.println(valY [i]);
  } 
  Serial.println();
 
  delay(2000);
}

Also here is the current wiring. Pretty messy but oh well i'll make it neater. It didn't attach in the earlier post for some reason...


Okay then I will keep the resistors as they are :slight_smile:

Use your volt meter to measure the voltage on each power rail of all the breadboards.

Each red/blue rail must be 5v.


Confirm with the meter, that all the resistors are actually 10k.


Cannot see the quality of your soldering on the MUX PCB.


“ 4.5-4.7 -without light for all; 1.2-1.35 for 3 ldrs and 2.5 for 1 ldr”

The range you should be getting are numbers like ~250 to ~1000

Some of the jumper wires look like they are not inserted all the way into the breadboard.

Hi,

Thanks once again for all the help. I rebuilt the whole thing after checking the volts of each breadboard and finding the exact 10k resistors.

Only problem I'm facing is the channel 7, which shows always 1023. I think my soldering might have been wrong. I reordered the piece to solder again. So I will see if it works today.

Thanks once again.


The values I shared for ldrs were voltages. I misunderstood your question. Sorry.


Also rewrote the code so I can unpack at max msp easily.


//16 channels analog multiplexer
//Pinout

// S0 -> Arduino Digital 8
// S1 -> Arduino Digital 9
// S2 -> Arduino Digital 10
// S3 -> Arduino Digital 11
// E -> Ardunio GND
// Z -> Arduino Analog A0
// VEE/ GND -> Arduino GND
// VCC -> Arduino + 5V
// Y0 to Y15 -> Analog Extended Pins

const byte sensePin = A0;


void setup()
{
  DDRB = 255;
  Serial.begin(9600);
}

void loop()
{
  int valY [12];

  for (byte i = 0; i < 12; i++) {
    PORTB = i;
    (void)analogRead(sensePin); // discard the first reading
    valY [i] = analogRead(sensePin);
  }

  for (byte i = 0; i < 12; i++) {
    Serial.print(valY [i]);
    Serial.print(" ");
  } 
  Serial.println();
 
  delay(100);
}

“ Only problem I'm facing is the channel 7”

Is this Y7 or Y6 the mux starts at Y0, zero relative.

Check or replace the Y7/Y6 wire as it might be bad.


There are many soldering videos on youtube; you should watch some of then.

Some examples:

Suggest you buy some liquid soldering flux to aid in you soldering; a Q-Tip woks well for applying.

https://www.amazon.com/s?k=liquid+flux&ref=nb_sb_noss_1

Strive to make the ‘Perfect’ example in the image below.


Move the 7th channel components to a different location, the breadboard might have a bad section.


Just in case, ‘never’ plug more the one lead into a hole on the breadboard.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.