Programmatically switch betwean ground, power, signal for input port
Six bits are not going to be enough to select between three states for each of the six pins. The number of different combinations is 3^6 (729). You need at least 12 bits to hold that value. If you can get eight bits for selection, you can use multiplexers to select the states. If you have an arduino, I would suggest ordering an ATMega328p or similar, and programming it through your Arduino with the included ArduinoISP sketch. This would give you plenty of I/O for the job.