I want to use an array to control output values. What can I do?

You set the value "brightness" outside the for loop...so it never changes. Either move it inside the loop or change your analogWrite to use pwmVals directly.

Steve