Switch on and off the multiplexer using the enable pin

Hi!
I want to use the enable pin for my multiplexer. Is this the right way? Thanks.

...
int EN = 13;  //define the enable pin

void setup(){
  ...
  pinMode(EN, OUTPUT); 
}

void loop(){
...
digitalWrite(EN, LOW);  //switch on enable pin 
... read output
digitalWrite(EN, HIGH);  //switch off enable pin
..
}

It looks correct but depending on the Arduino that you are using then you may want to reconsider the use of pin 13 as it is used for the built in LED on some boards

Thanks for your hint! I will check the pin 13.
I use the ardunoUNO with an Adafruit Datalogging shield. My code works but when I add the 2 lines; digitalWrite(EN, LOW) and digitalWrite(EN, HIGH) to switch on and off the mux it gets crazy

Which multiplexer chip are you using ?
A schematic of your circuit would be helpful

I use a multiplexer CJMCU-4051 74HC4051

Do you mean the Uno stops running?

The problem is the SD card which on the adafruit datalogging shield uses the digital pin 13 for the SPI communication (ICSP SCK - SPI clock)... Thanks for your help!

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