I'm trying to make an ultrasonic senor which sets of a buzzer whenever the measured distance is below a certain value (40cm), however the buzzer is going off constantly when I run the program because on the serial monitor the distance reads zero in between each actual value that's accurately read. Code below.
ok so it looks like every second echo isnt being returned in time and is giving the zero, i played around with time out times and for some reason every second echo isnt coming back, any idea why this would happen?
nice, that made it work, thanks! i thought i had to change the delays that were already in place and just make them longer, didn't realise i actually had to put a new one in