On Mon, 2023-04-17 at 15:14 -0500, Rick Snow wrote:
Ultimately this person would like to control about 40 solenoids with an arduino mega and a pd patch.
I only noticed now that the intention is to control solenoids. I was once triggering solenoids with Pd and an Arduino and was not quite satisfied with StandardFirmata because of the jitter between the 'on' and 'off' message. Thus, I implemented a simple protocol where the pin number and pulse length are part of the same message, so that the timing is only dependent on the boards own clock and not the serial bus. This allowed for more fine-grained control over the solenoid's velocity.
The code (sketch and abstraction) is here: https://netpd.org/~roman/tmp/solenoiduino.zip
Please note, that the protocol can only control 16 solenoids and has a timing resolution of 2*10 (1024 steps). You could add two more bits to the solenoids addressing and remove two bits from the timing. Or you could extend the protocol to a message length of 3 bytes.
Roman