Millis and ultrasonic sensor

This tutorial may be of help. It gives an example of how to use millis() and a simple state machine that uses a very similar sequence to the one you want.