A function to write several digital outputs at once (C++ level)

Please, notice that the loop is just for the number of pins, not for their locations, which are specified by pinIni and pinFinal.