@skibsradio, if you search this forum you will find examples of multiple timed events. I recall a sprinkler system for example.
If you are new to programming, you may need to learn some basics before trying a more advanced project. Using @ScruffR’s advice, your project would need the following I believe:
- An array of six unsigned integer values to store time (in seconds) values for each of the 6 outputs you want to control. Using a two-dimensional array you could store the GPIO pin number and its corresponding timer value together.
- Create a free-running Software Timer with a one second interval, assuming the minimum time for keeping an output “active” is one second.
- In your Particle.function() you would parse the passed command string (eg. using
sscanf()) to get the output number and the time it needs to remain “active” after which it is set “inactive”. That time value would be stored in the corresponding array value (for that output).
- In the Software Timer callback and using a
for() loop, check if all timer array entries for a non-zero value and decrement it. If it reaches zero, set the corresponding output to “inactive”, otherwise continue checking the other timer values. Any timers with zero value will be ignored.
Basically, the Particle.function() sets an output and its corresponding timer value (in seconds) while the Software Timer callback will, at one second intervals, check if any output needs to be set to “inactive”.