Get I/0 variables

Take a look at this sample, it reads the collection of I/O’s and allows the user to toggle them by button push.
It sounds like what you are looking for.