I have an Uno hooked up to a sparkfun 8 channel multiplexer (https://learn.sparkfun.com/tutorials/multiplexer-breakout-hookup-guide). I have it wired up like this:
Arduino0 --> S0
Arduino1 --> S1
Arduino2 --> S2
Arduino3 --> Z
Arduino 5v --> VCC
Arduino GND --> GND
I'm running a simple code to blink two different LED's, one attached to Y7, and one attached to Y6.
//Define MUX pins
int pin0 = 0;
int pin1 = 1;
int pin2 = 2;
int zOutPut1 = 3;
void setup() {
Serial.begin(9600);
// Set controll pins
pinMode(pin0, OUTPUT);
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(zOutPut1, OUTPUT);
}
void loop() {
samplerStarter();
}
void samplerStarter() {
sample(1); // Takes sample for 5 min
delay(1000);
sample(2);
delay(1000);
}
void sample(int noidNum){
//MUX 1
if(noidNum == 1) {
digitalWrite(pin0, HIGH);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(zOutPut1, HIGH); //Y7
}
else if (noidNum == 2) {
digitalWrite(pin0, LOW);
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
digitalWrite(zOutPut1, HIGH); //Y6
}
delay(500);
//Set everythign back to Low
digitalWrite(pin0, LOW);
digitalWrite(pin1, LOW);
digitalWrite(pin2, LOW);
digitalWrite(zOutPut1, LOW);
delay(500);
}
But when I run this code, only the first LED attached to Y7 blinks. But if I remove the Serial.begin(9600)
line:
//Serial.begin(9600);
Everything works fine. So I have no idea why this one line dealing with Serial Communication is affecting my multiplexor.