In this project I worked on the arduino. I made an pulse controller. With that you can control the amount of pulses and the pulse time of the relay. Link to the code: click here
I made this script building on the [arduino spi demo script]. The parts I am going to explain are only for my script part.