Two solenoids for a metronome device

Try using timer.timeOut() or timer.setTimer() timers… I did something similar for adjustable timing here. You will have to extrapolate the logic needed for your purposes.