I'm certain there are more elegant ways to do this. An array, for instance, and writing directly to a port.