i am trying to make functions and variabel separate from the main loop . i created it all the main info what is needed just still i get an error about not declared in this scope.
you are promising the compiler that this function will return an int but it does not return anything...
distance is a local variable to the function, different than the one you use for calling ➜ you want to pass this one by reference (same for duration if you want it back)
and for your error, what's the business of trigpin versus pingPin?
please edit your post, select the code part and press the </> icon in the tool bar to mark it as code. It's barely readable as it stands. (also make sure you indented the code in the IDE before copying, that's done by pressing ctrlT on a PC or cmdT on a Mac)