The first code is for the transmitter code and the second code is for the receiver.
These Hc-sro4 ultrasonic sensors you need to send out a ping before they start to receive, that is why I ping it (the receiving sketch) so that it starts receiving.
Is there another way?