Recently I came across a post about developing a automated focus stacking. It uses and Arduino based controller at the heart of it. You can then program the Arduino appropriately. I have had no experience with Arduino. But I have decided to do one myself. So watch this space for more updates..