- This topic has 0 replies, 1 voice, and was last updated 7 years, 5 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Home › Forums › Mux Shield (Original) Support › A Question About "Analog Input Example Code"
So, I am making a new kind of instrument and your MUX and accompanying code is just what I am looking for. My question about the code is more of a theoretical one that a practical one. In your code, you loop through the First MUX taking just the analogRead[0]. You then loop through the Second MUX taking just the analogRead[1]…and so on. Is there a particular reason that you did it that way rather that the code below.
for (int i=0; i<16; i++)
{
digitalWrite(CONTROL0, (i&15)>>3);
digitalWrite(CONTROL1, (i&7)>>2);
digitalWrite(CONTROL2, (i&3)>>1);
digitalWrite(CONTROL3, (i&1));
mux0array[i] = analogRead(0);
mux1array[i] = analogRead(1);
mux2array[i] = analogRead(2);
}
Would the code I provided not be more performant? Perhaps your code helps prevent analog cross talk? Or is more performant for some reason I do not understand? Honest question here.