Hello!
I am currently trying to multiplex 16x UGN3144 Hall Effect sensors using a CD74HC4067, my final goal being to create a 8x8 array of them (chess board). I already know that the UGN3144 gives a digital output and that the CD74HC4067 expects analog input, but I thought that wouldn't be much of an issue.
Please do excuse the horrendous wiring and overall low quality of the schematic as well as the fact that there is only one hall sensor in the image.
Try to imagine 15 more sensors wired up in the exact same manner, but for different channels.
GND, EN -> GND
S0 -> D2
S1 -> D3
S2 -> D4
S3 -> D5
C0,1,2... -> output of the UGN3144 -> 10k Ohm pull down resistor
SIG -> A0
The VCC is provided by Arduino's VBUS pin -> 5V
Using this code:
//Mux control pins
int s0 = D2;
int s1 = D3;
int s2 = D4;
int s3 = D5;
//Mux in "SIG" pin
int SIG_pin = A0;
void setup(){
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);
Serial.begin(9600);
}
void loop(){
//Loop through and read all 16 values
//Reports back Value at channel 6 is: 346
for(int i = 0; i < 16; i ++){
Serial.print("Value at channel ");
Serial.print(i);
Serial.print("is : ");
Serial.println(readMux(i));
delay(100);
}
}
int readMux(int channel){
int controlPin[] = {s0, s1, s2, s3};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
//loop through the 4 sig
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin[i], muxChannel[channel][i]);
}
//read the value at the SIG pin
int val = analogRead(SIG_pin);
//return the value
return val;
}
I get 0 from all channels even though I should technically get 4096 when triggering any of the sensors with a magnet.
What am I doing wrong? Any suggestion is appreciated. Thank you!







