tinkerspy / Automaton

Reactive State Machine Framework for Arduino
https://github.com/tinkerspy/Automaton/wiki
MIT License
369 stars 63 forks source link

Using same UNO pin with Digital & Button Machines #55

Open Mike58501 opened 6 years ago

Mike58501 commented 6 years ago

Tinkerspy &/or other Automaton person, If the project coder is running LOW on UNO pins & also wanted to save by using one less wire to & from a relay switch leg ... is it ever permissible to use the Automaton Digital Machine & the Automaton Button Machine with the same pin (9) as two separate reactions to the same change. For example: Digital to change an Automaton State & Button to change an LCD message? Both would be using Pin 9's _inputpullup declaration so the change in the UNO ground presence on the pin is what the pin (9) would be reacting to. Thanks. Just checking ... just in case there is potentially a conflict within Automaton itself. Don't want to oversimplify or over complicate ... no no ... not this American Citizen. Thanks

matthijskooijman commented 5 years ago

@Mike58501, did you ever just try this? From what I know of how digital and button work, I would suspect they would just both read the same pin and work fine (except that for very short pulses, I can imagine that one of them will fire but not the other, which could be problematic). A slightly more efficient version that does not poll the pin twice every time would be to use the fan machine to trigger multiple events from one digital or button, or to trigger multiple events from an onChange lambda function.

Mike58501 commented 5 years ago

Thanks for the thoughts about the considerations & implications for doing what I suggested. It did turn out that the more than one pin with wires branching out in parallel would just see the now showing up common ground which made it do-able for my application. Correct me if I am wrong ... but it seems like Tinkerspy's Framework would be better if it had examples that were not just pretty much limited to just one specific sequential operation which reflects more to just a "game playing" mindset IMHO vs something more worthwhile in real life.