loveaurell
Well-known member
I'm trying to implement a small scale version of this circuit https://www.pjrc.com/teensy/schematic_ioexpand.png
I'm using one 74HC4051 and two linear 10k pots. The output of the 74HC4051 is fed to A0, and digital pins 2 3 4 is controlling the channels on the 74HC4051.
The 6, 7 and 8 pins on the 74HC4051 are connected to ground. Pin 16 is connected to +5V.
However, the two linear 10k pots I'm using seems to affect each other when connected through the 74HC4051. And the values are not linear, one of the pots are increasing slowly until approximately 70-80% and then moves quickly up to max value. When I connect the pots direcly to two separate analog pins on the teensy, they seem to behave as expected. I have tried to replace the 74HC4051 but got the same result.
Is there something I have overlooked here? Is 10k a suitable potentiometer value?
I'm using one 74HC4051 and two linear 10k pots. The output of the 74HC4051 is fed to A0, and digital pins 2 3 4 is controlling the channels on the 74HC4051.
The 6, 7 and 8 pins on the 74HC4051 are connected to ground. Pin 16 is connected to +5V.
However, the two linear 10k pots I'm using seems to affect each other when connected through the 74HC4051. And the values are not linear, one of the pots are increasing slowly until approximately 70-80% and then moves quickly up to max value. When I connect the pots direcly to two separate analog pins on the teensy, they seem to behave as expected. I have tried to replace the 74HC4051 but got the same result.
Is there something I have overlooked here? Is 10k a suitable potentiometer value?
Code:
const int pinChannelBit1 = 2;
const int pinChannelBit2 = 3;
const int pinChannelBit3 = 4;
const int controlInput1 = 14;
int potValue;
void setup() {
pinMode(pinChannelBit1, OUTPUT);
pinMode(pinChannelBit2, OUTPUT);
pinMode(pinChannelBit3, OUTPUT);
analogReadResolution(7);
}
void loop() {
selectPinChannel(0);
potValue = analogRead(controlInput1);
Serial.print("Pot 1: ");
Serial.println(potValue);
selectPinChannel(1);
potValue = analogRead(controlInput1);
Serial.print("Pot 2: ");
Serial.println(potValue);
Serial.println();
delay(500);
}
// select 74HC4051 channel
void selectPinChannel(int channel) {
digitalWrite(pinChannelBit3, HIGH && (channel & B00000100));
digitalWrite(pinChannelBit2, HIGH && (channel & B00000010));
digitalWrite(pinChannelBit1, HIGH && (channel & B00000001));
delayMicroseconds(50);
}
Last edited: