Analog In Example Not Working With Mux Shield

I got a Mux Shield II: Mux Shield II | Mayhew Labs

I uploaded the analog in example code:

//This example shows how to use the Mux Shield for analog inputs

#include <MuxShield.h>

//Initialize the Mux Shield
MuxShield muxShield;

void setup()
{
    //Set I/O 1, I/O 2, and I/O 3 as analog inputs
    muxShield.setMode(1,ANALOG_IN);
    muxShield.setMode(2,ANALOG_IN);
    muxShield.setMode(3,ANALOG_IN);
    
    Serial.begin(9600);
}

//Arrays to store analog values after recieving them
int IO1AnalogVals[16];
int IO2AnalogVals[16];
int IO3AnalogVals[16];

void loop()
{
  for (int i=0; i<16; i++)
  {
    //Analog read on all 16 inputs on IO1, IO2, and IO3
    IO1AnalogVals[i] = muxShield.analogReadMS(1,i);
    IO2AnalogVals[i] = muxShield.analogReadMS(2,i);
    IO3AnalogVals[i] = muxShield.analogReadMS(3,i);
  }
  
  //Print IO1 values for inspection
  Serial.print("IO1 analog values: ");
  for (int i=0; i<16; i++)
  {
    Serial.print(IO1AnalogVals[i]);
    Serial.print('\t');
  }
  Serial.println();
}

When I connect a photoresistor to the IO1 row in pin zero and cover the photoresistor, the readings for the whole IO1 row change with it. Is there any way to stop this from happening?

Another problem, when I attach two photoresistors to the shield, in pins zero and one, for example, the readings only change for the photoresistor in pin zero and not in one. Why might this be?

Thanks,
Tim

Hi,
If you have nothing connected to the unused analog inputs, they are floating, it looks like they are ghosting the other input.

Try connecting your unused analog inputs to gnd and see if that fixes it?

Tom... :slight_smile:

Before I do this, it is okay if I solder all the pins on the Arduino to the shield except for pin 9? I want to use pin 9 to power a speaker directly from the Arduino.

Hi,
Your shield should plug into the top of the UNO, why solder?

Tom... :slight_smile:

It is not a firm connection; the shield jiggles around a bit and messes up the readings.

Would it be okay to solder all pins except for 9?

Hi,
Give it a try, it may fix some of your problems if it isn't a good fit.

All the shields I have had are usually very tight and hard to pull form the controller PCB when I want to remove them.

Tom... :slight_smile:

I soldered to board to the Arduino and grounded the inputs as you suggested, and IO1 now works perfectly. Thank you very much for you help!