I'm not sure what this is called.
I notice that pulseIn takes three arguments. One is the pin, one is the value of the pulse to be measured, and one is the timeout. If no timout is passed to pulseIn, it times out in 1 second be default.
I can think of one way to create a function with this kind of "defaulting" behavior...create two functions, one with three arguments and another with only two arguments that has the third argument hard-wired to a default value. I think that's called function overloading. But that's wasteful.
Is there a better way to do this ? I think in java I think you can do something like this when you create a function
long myfunction(int pin=1, bool me=1, int time=1, long time1=1)
then if you use the function else where, if you just do
then it will be the same as running
and if you ran
it would be the same as running
does this work in arduinoland?