Hello, On my nano board, I want to output 1-second HIGH unrelated pulses on six pins, based on selection from a UART (for example) ..
Would a single 1s timer nested six deep work?
1S pulse accuracy not critical.
Thanks
Hello, On my nano board, I want to output 1-second HIGH unrelated pulses on six pins, based on selection from a UART (for example) ..
Would a single 1s timer nested six deep work?
1S pulse accuracy not critical.
Thanks
I don’t think that nesting is the answer. I would use an array of millisecond values.
void loop()
{
unsigned long currentTime = millis();
for (int i=0; i<TIMER_COUNT; i++)
{
if (Timers[i] != 0 && currentTime - Timers[i] >= 1000)
{
digitalWrite(OutputPins[i], LOW);
Timers[i] = 0; // Done with the timer
}
}
// To start a pulse on output 'n':
Timer[n] = currentTime; // Start the timer
digitalWrite(OutputPins[n], HIGH);
}
your code is a bit confusing, please include all of it.
gilshultz:
your code is a bit confusing, please include all of it.
That is all that I wrote. You did not give enough information to write more.
Is there some particular part that you find confusing? Perhaps I can add more comments to help you understand.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.