hello,
i'm using 5 slave 4051 and 1 master 4051 to build a 40 channel multiplexer. 40 potentiometers (100k) are connected to the analog ins on each 4051.
the arduino is reading all the inputs, but is messing aroung with neighbour-inputs. e.g.: when i turn potentiometer #32 from 0 to 1023, then the value of potentiometer #31 is changing to (~)760... and the other way round. on different potentiometers the similar situation, sometimes more sometimes less affection...
each potentiometer is getting its ground and +5v from the arduino, the middle pins are connected to the slave 4051 analog inputs, each output of an slave 4051 is connected to the master 4051 analog input, just like in the basic description:
http://playground.arduino.cc/learning/4051Any idea how to clear the values?
I'm using this mux example to read out the values:
#include <analogmuxdemux.h>
#define READPIN 2 //analog in
#define NO_PINS 40 //40 inputs
// master selects
#define M_S0 10 //master digital pin
#define M_S1 11 //master digital pin
#define M_S2 12 //master digital pin
// slave selects
#define S_S0 2 //slave digital pin
#define S_S1 3 //slave digital pin
#define S_S2 4 //slave digital pin
AnalogMux amx(M_S0,M_S1,M_S2, S_S0,S_S1,S_S2, READPIN);
void setup() {
// check in serial monitor what is happening
Serial.begin(9600);
Serial.println("Starting 4051 analog reader...");
delay(1000);
}
void loop() {
// go through each pin on the muxer in turn and just print out it's pin number
// and it's reading then wait a bit and do it again
for (int pinno=0; pinno< NO_PINS; pinno++) {
amx.SelectPin(pinno);
uint16_t reading = amx.AnalogRead();
Serial.print("Pin: ");
Serial.print(pinno);
Serial.print(" Value: ");
Serial.print(reading);
Serial.println();
}
Serial.println("---");
delay(1000);
}