Merge the two setup () functions, then take all the code in loop() from the sonar sketch and make it a function returning a range.
Merge the two setup () functions, then take all the code in loop() from the sonar sketch and make it a function returning a range.