I don't have a 4051 on hand to test, but the attached patches should work for input and output.
triggering pin 13 (led) is optional. They do it in the example to show you that the code is initialized. In my puredata example, I do the same.
For most things you can translate the examples pretty directly, so "pinMode 3" is the same as what you send to the arduino object. "digitalWrite(13, HIGH)" is "digital 13 1" in puredata. I'm doing the loop in puredata with metro and mod8 to loop through all the inputs, and converting them to 3-digit binary. On output, I'm just packing the address with the slider data (no loop needed.)
In this example, wire your 4051 up like this:
MULTPILEXED ANALOG INPUT
[pot] [pot] [pot] [pot] [pot] [pot] [pot] [pot]
| | | | | | | |
y0 y1 y2 y3 y4 y5 y6 y7
| | | | | | | |
--------------------------------------------
| |
| 4051 |
| |
--------------------------------------------
| | | |
s0 s1 s2 z
| | | |
| | | |
d2 d3 d4 a0
| | | |
--------------------------------------------
| |
| ARDUINO |
| |
--------------------------------------------
DEMULTPILEXED ANALOG OUTPUT
[led] [led] [led] [led] [led] [led] [led] [led]
| | | | | | | |
y0 y1 y2 y3 y4 y5 y6 y7
| | | | | | | |
--------------------------------------------
| |
| 4051 |
| |
--------------------------------------------
| | | |
s0 s1 s2 z
| | | |
| | | |
d2 d3 d4 d5 (PWM)
| | | |
--------------------------------------------
| |
| ARDUINO |
| |
--------------------------------------------
http://www.pdpatchrepo.info/hurleur/demultiplex_arduino_4051_input.pd