pinMode occurs before setting variables


#1

Is there anyway to set the variables before pinmode?
Otherwise we need to remember the pin numbers all the time?
See attached, line 31 occurs first, then after that the set variables happen.

Is there a way to set variables first so we dont need to hard code pins?
In this example, I can use variables for the trigger/echo pin, but thats just lucky as those pinModes happen in getDistance.


#2

Hi, you can copy the code, then open ArduinoC mode and paste the code into ArduinoC, then you can rearrange it: