distance sensor and timing

When first in your do_loop, you never get out!