Arduino, and Mechanical Movement of Objects - a Newbie Question

Retroplayer:
The only limitation to it is that the OP mentions variable widths. This could be solved with a square shaft that he can slide on different lengths of these at different points depending on how many piles he is trying to make and how wide.

I think it's can be simpler than that. Just have a long shaft with the spirals milled all along it. Then you put "stops" along the shaft where required. Bit hard for me to explain but if the stops are just either side of a "X" part of the spirals it basically turns that location into the end of the shaft and causes the cam follower to reverse at that point.