Quantcast
Channel: Comments for miscellanea.com || andrew burrell
Viewing all articles
Browse latest Browse all 11

Comment on how to get more arduino analog inputs by andrew

$
0
0

Hi,

The loop function “void loop()” is where the guts of any arduino code goes. It simply loops through its instructions continually while the arduino is powered up.

So what you need to do is hook up all 8 piezos using the input pins of the multiplexer, then in the loop function read each of these pins in turn. (by setting s0, s1 & s2 to high or low according to what pin you are up to reading)

You cannot, in reality, read all of the 8 pins at once, you need to run through them in turn, but you do it fast enough that it makes no real difference to the user.

basically what you will be doing to the code above is adding 6 more code segments like the following but changing the LOW and HIGHS and also changing the variable name for each to make it unique (ie: readInTwo). This will switch through the inputs reading them in turn. If it seems laggy i would try removing or shortening the delay

digitalWrite(8, LOW);

digitalWrite(9, HIGH);

digitalWrite(10, LOW);

delay(10);

int readInTwo= analogRead(0); //change this variable name to be unique for each pin

//do some stuff with the value you just got

hope this helps
andrew


Viewing all articles
Browse latest Browse all 11

Trending Articles