Multiplexer 74hc4067 not reading A0 pin

Hey guys, I've been trying to use mux 74HC4067 to verify voltage divider rule. But for some reason My A0 pin is never activated causing the whole program to show a Row's of 0's in Virtual terminal. I followed the link below

The code and proteus diagram is given and i recreated it but the only change i made was instead of using Variable resistor i used normal resistor. But i doubt that would cause any problem as all my digital pins are activated in arduino but A0 is not lighting up so i think it's inactive all the time.
Here is my circuit and code below:

#define analogPin0 
int s0 = 5;
int s1 = 6;
int s2 = 7;
int s3 = 8;
 
void setup() {
  // Atur pin select sebagai output
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
   
  Serial.begin(9600);
}
 
void loop() {
  /* CD74HC4067 Module Analog Multiplexer 16-Ch Analog Digital 74HC4067
     Ubah-ubahlah nilai S0, S1, S2, dan S3 untuk memilih input mana yang digunakan berdasarkan tabel berikut:
  
  S0  S1  S2  S3  y ke-
  0   0   0   0   0
  1   0   0   0   1
  0   1   0   0   2
  1   1   0   0   3
  0   0   1   0   4
  1   0   1   0   5
  0   1   1   0   6
  1   1   1   0   7
  0   0   0   1   8
  1   0   0   1   9
  0   1   0   1   10
  1   1   0   1   11
  0   0   1   1   12
  1   0   1   1   13
  0   1   1   1   14
  1   1   1   1   15
 
  Catatan: 0 berarti LOW dan 1 berarti HIGH pada Arduino
  */
 
  // Pilih y0 sebagai input
  digitalWrite(s0, LOW);  //0   0   0   0   0
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  int sensorValue1 = analogRead(A0);
  float voltage1 = sensorValue1 * (5.0 /1023.0);
  delayMicroseconds(200);
 
 
  // Pilih y1 sebagai input
  digitalWrite(s0, HIGH); //1   0   0   0   1
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  int sensorValue2 = analogRead(A0);
  float voltage2 = sensorValue2 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y2 sebagai input
  digitalWrite(s0, LOW); //0   1   0   0   2
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  int sensorValue3 = analogRead(A0);
  float voltage3 = sensorValue3 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y3 sebagai input
  digitalWrite(s0, HIGH);//1   1   0   0   3
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  int sensorValue4 = analogRead(A0);
  float voltage4 = sensorValue4 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y4 sebagai input
  digitalWrite(s0, LOW);//0   0   1   0   4
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, LOW);
  int sensorValue5 = analogRead(A0);
  float voltage5 = sensorValue5 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y5 sebagai input
  digitalWrite(s0, HIGH);//1   0   1   0   5
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, LOW);
  int sensorValue6 = analogRead(A0);
  float voltage6 = sensorValue6 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y6 sebagai input
  digitalWrite(s0, LOW);//0   1   1   0   6
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, LOW);
  int sensorValue7 = analogRead(A0);
  float voltage7 = sensorValue7 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y7 sebagai input
  digitalWrite(s0, HIGH);//1   1   1   0   7
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, LOW);
  int sensorValue8 = analogRead(A0);
  float voltage8 = sensorValue8 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y8 sebagai input
  digitalWrite(s0, LOW);//0   0   0   1   8
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, HIGH);
  int sensorValue9 = analogRead(A0);
  float voltage9 = sensorValue9 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y9 sebagai input
  digitalWrite(s0, HIGH);//1   0   0   1   9
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, HIGH);
  int sensorValue10 = analogRead(A0);
  float voltage10 = sensorValue10 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y10 sebagai input
  digitalWrite(s0, LOW);//0   1   0   1   10
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  digitalWrite(s3, HIGH);
  int sensorValue11 = analogRead(A0);
  float voltage11 = sensorValue11 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y11 sebagai input
  digitalWrite(s0, HIGH);//1   1   0   1   11
  digitalWrite(s1, HIGH);
  digitalWrite(s2, LOW);
  digitalWrite(s3, HIGH);
  int sensorValue12 = analogRead(A0);
  float voltage12 = sensorValue12 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y12 sebagai input
  digitalWrite(s0, LOW);//0   0   1   1   12
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, HIGH);
  int sensorValue13 = analogRead(A0);
  float voltage13 = sensorValue13 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y13 sebagai input
  digitalWrite(s0, HIGH);//1   0   1   1   13
  digitalWrite(s1, LOW);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, HIGH);
  int sensorValue14 = analogRead(A0);
  float voltage14 = sensorValue14 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y14 sebagai input
  digitalWrite(s0, LOW);//0   1   1   1   14
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, HIGH);
  int sensorValue15 = analogRead(A0);
  float voltage15 = sensorValue15 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  // Pilih y15 sebagai input
  digitalWrite(s0, HIGH);//1   1   1   1   15
  digitalWrite(s1, HIGH);
  digitalWrite(s2, HIGH);
  digitalWrite(s3, HIGH);
  int sensorValue16 = analogRead(A0);
  float voltage16 = sensorValue16 * (5.0 /1023.0);
  delayMicroseconds(200);
 
  Serial.print(voltage1);
  Serial.print(" ");
  Serial.print(voltage2);
  Serial.print(" ");
  Serial.print(voltage3);
  Serial.print(" ");
  Serial.print(voltage4);
  Serial.print(" ");
  Serial.print(voltage5);
  Serial.print(" ");
  Serial.print(voltage6);
  Serial.print(" ");
  Serial.print(voltage7);
  Serial.print(" ");
  Serial.print(voltage8);
  Serial.print(" ");
  Serial.print(voltage9);
  Serial.print(" ");
  Serial.print(voltage10);
  Serial.print(" ");
  Serial.print(voltage11);
  Serial.print(" ");
  Serial.print(voltage12);
  Serial.print(" ");
  Serial.print(voltage13);
  Serial.print(" ");
  Serial.print(voltage14);
  Serial.print(" ");
  Serial.print(voltage15);
  Serial.print(" ");
  Serial.println(voltage16);
}

Here's your basic circuit with all the clutter stripped away.

analog mux simple.png

You just have a bunch of resistors in parallel across the power supply. A pot. is a variable voltage divider. If you want it to work put two resistors in series and take your input from the junction between them.

analog mux simple.png

True but shouldn't the output show 5V for all the nodes then?? My output shows 0.00 in a 1*16 row matrix. also my A0 is always Gray meaning it's never active.

I don't see Vcc on the mux connected (pin 24).

Hello linkinpark22,

Welcome and well done for posting your code correctly.

I might or might not have something helpful to offer you but I can't see your schematic. Dougp has kindly looked at it and even posted part of it, but I don't share his enthusiasm for looking on other web sites. Please can you post your schematic on this web site as per the instruction you have surely read. If I see something I can help with I will, more importantly others who share my dislike of looking on other web sites might also offer you help if they can.

Thanks.

I'll keep that in mind @PerryBebbington....... The problem is that my proteus schamatics is too large to fit in properly in an image so i took out a zoom out image of it. and @dougp there is no pin 24 in the mux i'm using. I tried to use a 3*8 mux project using pot to verify voltage divider but still A0 pin does not get activated so i get 0.00 as output. is it permissible to share proteus file in this forum so someone can have a better look at the simulation??
and sorry English is not my main language :frowning:

linkinpark22:
and @dougp there is no pin 24 in the mux i'm using

I beg to differ.

In schematic programs, many symbols omit the Vcc and GND pins on packages; you have to refer to the data sheet ‘ALWAYS’.

I understand somethings from the actual hardware and the simulation software might differ....but from the simulation aspect why ism't my A0 pin getting any reading?

If you do not have pin 24 and 12 connected how is the I.C. being powered ?

larryd:
If you do not have pin 24 and 12 connected how is the I.C. being powered ?

My guess would be from the main power sources which is powering the circuit(See 2 power sources in the pic you attached) since the IC and the main circuit is both connected to the power source it should be providing power to both systems(do keep in mind simulations aren't always practical).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.