getting ultrasonic sensor to change its direction from previous

Variables store a value. In this case the value true or false (basically 1 or 0).