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

You have a global variable called 'i' that sets brightness, then multiple locals also called 'i'.

Could that be what is confusing you?

Why not an array of output pins?