This is the code I used for calculating the speed of sound with a simple circuit
This mini project is a simple circuit using the arduino software that consist only of the ultrasonic sensor component, jumper wires and UNO R3 microcontroller.
It's pretty easy to make and the wiring is not too complicated.
I'll add the link to the schematic diagram so it'll be easier for you to reproduce and have fun with it as I did!
My setup: https://drive.google.com/file/d/0BzK-D1VJ13yMMF9MZTUycnRGaWs/view?usp=sharing
Wiring: https://drive.google.com/file/d/0BzK-D1VJ13yMaU5qdTJsUEZ6aEE/view?usp=sharing
Schedmatic Diagram (made with Fritzing) https://drive.google.com/file/d/0BzK-D1VJ13yMWTVscmFFM1dkVE0/view?usp=sharing
My results: https://drive.google.com/file/d/0BzK-D1VJ13yMUS1tNF9ERWVpbnM/view?usp=sharing https://drive.google.com/file/d/0BzK-D1VJ13yMWE0wUXpWSzZtbEE/view?usp=sharing