*URGENT* proximity sensor code not working

I think I have got the code working now. Thank you everyone.