My project needs to read 4 analog inputs. I went through some threads of the forum and learnt that I cant use this code since Atmega 328 ADC multiplexer needs time to switch channels to the ADC.
Ill have to use delay() for the above code to work. But I cant compromise on analog sampling frequency for my project. So i decided to use the 4052 analog multiplexer.
I'm using grey code to change analog channels serially one after the other.(00,01,11,10)
Will the latter approach give correct ADC readings and a greater ADC sampling frequency?
Code:
void loop(){
a=analogRead(0);
b=analogRead(1);
c=analogRead(2);
d=analogRead(3);
}
I'm using grey code to change analog channels serially one after the other.(00,01,11,10)
Code:
void loop(){
digitalWrite(2,0);
digitalWrite(3,0);
a=analogRead(0);
digitalWrite(2,1);
b=analogRead(0);
digitalWrite(3,1);
c=analogRead(0);
digitalWrite(2,0);
d=analogRead(0);
}