I am trying to get a Multiplexer to work with the Arduino. Description at sparkfun Datasheet
I thought the wiring was pretty simple and as a basic test, I have AREF connected to C1(multiplexer) and a floating wire connected to C0. Everything on the interfacing side maps almost 1 to 1 with the arduino.
I am using this simple code for switching the multiplexer
void select_wire(char which){
digitalWrite(S0,which&0x01);
digitalWrite(S1,which&0x02);
digitalWrite(S2,which&0x04);
digitalWrite(S3,which&0x08);
digitalWrite(EN,0);
delay(1); //required?
}
and then I just read from the Analog pin at S
on the multiplexer. My problem is that it is not switching! How do I fix this so that it will behave as intended and give a zero(or close) whenever I do select_wire(1)
and read the analog pin?
Also, I am not using the Wiring "language" but I am using the Wiring library. I have also set all the appropriate pinMode
s in the init