Perhaps it would help if you describe what you are trying to do, I know you want to read inputs and control some outputs but you have not said anything about time for readings/switching etc.
Please describe the problem you are trying to solve or what you are trying to control and maybe we can...