Ultrasonic sensor with LED, how can I do this?

If you really can't assemble that, you're essentially asking someone to code for you. You should either post specific attempts, along with the specific compiler error output, or else pay someone to do it.

By the way, so far I have not seen any variable to keep track of what event is "next time". In your description you talk about an alternating sequence but the program can't know what the previous state was without storing it somehow.