Arduino TollGate with ultrasonic & rfid & servo

Hello guys.

Im doing project for my school and I started doing arduino smart tollgate. I’v been doing fine so far until i got stuck in while loop. I want my ultrasonic sensor to protect my car from toll. Any help would be great thanks.

sketch_toll.ino (11.2 KB)

I assume the while loop that you are stuck in is this one:

        while ( distance < 4){
         
           delay(500);
          
        }

If that loop is entered the value of distance never changes and yes, you will be stuck in it. There is a block of code at the beginning of loop() that sets the value of distance, you need to also include it in that while loop, it’s the only chance you’ll have of getting out of it.

Thank you verry much :D.