MuxShield II issue writing channels

Hello,

I’m using the Mayhem labs MuxShield II (Mux Shield II | Mayhew Labs) with a SparkFun redboard

I’m configuring the shield to use digital outputs. Whenever I write a channel, the other channels get cleared. I’m not quite sure why this is happening.

I’ve adapted the test code below from the MuxShieldDigitalOut example sketch.

At any given point in the loop the only pins that are high (5V) are associated with the channel that was last written to. The expected behavior would be that after the first iteration through the loop Channels 1:3, pins 1:3 would be high.

Thanks!

#include <MuxShield.h>

//Initialize the Mux Shield
MuxShield muxShield;

void setup() {
  // put your setup code here, to run once:
  // initialize serial:
  Serial.begin(9600);

  //Set I/O 1, I/O 2, and I/O 3 as digital outputs
  muxShield.setMode(1,DIGITAL_OUT);  
  muxShield.setMode(2,DIGITAL_OUT);
  muxShield.setMode(3,DIGITAL_OUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1);
  Serial.println("Configuring Channel 1, pins 1,2,3");
  muxShield.digitalWriteMS(1,1,1);
  muxShield.digitalWriteMS(1,2,1);
  muxShield.digitalWriteMS(1,3,1);  
  
    
  delay(5000);
  Serial.println("Configuring Channel 2, pins 1,2,3");
  muxShield.digitalWriteMS(2,1,1);
  muxShield.digitalWriteMS(2,2,1);
  muxShield.digitalWriteMS(2,3,1);
 
  delay(5000);
  Serial.println("Configuring Channel 3, pins 1,2,3");
  muxShield.digitalWriteMS(3,1,1);
  muxShield.digitalWriteMS(3,2,1);
  muxShield.digitalWriteMS(3,3,1);
  delay(5000);
}

Hi,
Welcome to the forum

Did you get the example code to work before you modified it?

Note that in each for loop they allow 100mS between EACH command.

You may need to do this:

  delay(100);
  Serial.println("Setting Channel 1, pins 1,2,3");
  muxShield.digitalWriteMS(1,1,1);
  delay(100);
  muxShield.digitalWriteMS(1,2,1);
  delay(100);
  muxShield.digitalWriteMS(1,3,1);
  delay(100);

I also changed Config to Setting in your serial.print, as you have already configured the I/O in setup.
(Just me being fussy :o)

Tom... :slight_smile: