Hello everyone,
I just started using the CD4067 with an UNO, in an attempt to read a series of digital inputs.
This is a test bed, just for learning at this point.
So, just one CD4067, ill add more later.
I already got pretty much the exact same thing working with some LEDs but now im trying to expand my inputs, not my outputs.
The issue seems to be that if I apply +5V to one pin, it seems to register on the adjacent 5 or 6 pins surrounding that pin!!! Which is not ideal at all for my application!
Very strange.
Has anyone had this problem before?
Here is my code
Thank you in advance for any help you guys can offer!!
/*
* CD4067 multiplexer attached as follows:
- address pin A: digital I/O 2
- address pin B: digital I/O 3
- address pin C: digital I/O 4
- address pin D: digital I/O 5
- input pin: digital I/O pin 6
- LEDs attached from each of the CD4067's output channels
to ground
*/
// put the address pin numbers in an array
// so they're easier to iterate over:
const int channel[] = {2, 3, 4, 5};
int value ;
// the output pin channel (mux's input):
void setup() {
Serial.begin(9600);
pinMode(2,OUTPUT); //A
pinMode(3,OUTPUT); //B
pinMode(4,OUTPUT); //C
pinMode(5,OUTPUT); //D
pinMode(6,INPUT); //Input
}
void loop() {
// iterate over the 16 channels of the multiplexer:
for (int thisChannel = 0; thisChannel < 16; thisChannel++) {
// chooses 0-15
// set the channel pins based on the channel you want:
// iterate over the number of pins you're using:
for (int thisPin = 0; thisPin < 4; thisPin++) {
// chooses channel array value 0,1,2,3 -> 2,3,4,5
// calculate the state of this pin based on
// its bit value in whichChannel:
digitalWrite(channel[thisPin],bitRead(thisChannel, 3-thisPin));
}
value = digitalRead(6);
Serial.print(thisChannel);
Serial.print("-");
Serial.println(value);
}
Serial.println(" ");
delay(1000);
}