Combining serial listening and output actions

Greetings!

Is it possible to have an Arduino listen to a serial input in parallell with it doing things with its local outputs?

I want to make a controller for LEDs that would do some simple animations (using non-blocking code) that can shift between modes when a command for that ("device 345, use pattern 12") comes on the serial input. The commands may come at any time and should be followed in less than a second.

Any guidance?

Yes, but you must implement the animations using non blocking code

See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE

Use hardware serial, not softwareserial !

Basically -
In your loop(), test serial.available often, read each bundle, then append any characters to your ‘input buffer’
When the message terminator (CR?) is received, process and clear your input buffer

Hello anwall

Firstly, a simple software protocol should be designed.
In a second step, the sequence parser should be designed and coded.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.