You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Arduino Leonardo has 12 Analog pins. But A6 - A11 pins (D24 - D29) are actually other pins that are being re-used (D4, D6, D8, D9, D10, and D12). it means D4 and D24 are the same physical pin.
Now, StandardFirmata (and probably others) threats those pins as separate pins while Arduino threats them as the same. So, during systemResetCallback, those physical pins are actually initialized twice in Firmata. Once as Digital output (e.g. D4) and then later as analog pin (A6 - D24). This leads to an inconsistency between Firmata and the board's state:
Firmata state (internal state, and reported to the client application):
D4 : OUTPUT
D24 (A6): ANALOG INPUT
Arduino (Board) state:
D4 - D24 - A6: ANALOG INPUT
As Firmata thinks that D4 is OUTPUT while it's actually ANALOG INPUT, a digitalWrite (from SET_DIGITAL_PIN_VALUE or DIGITAL_MESSAGE) on D4 will not do anything.
I don't know if other Arduino boards also remap existing pins or if it's specific to Leonardo. So I'm not sure what's the best way to fix this issue.
Work around: By not using pins D4, D6, D8, D9, D10, and D12, but their equivalent pin number (D24 - D29), Firmata and Arduino states are consistent and work as expected.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. Do you have an idea on how this should be fixed? Since there are seemingly two ways of addressing the same physical pin, your workaround is probably the best you can do. We could remove the pins D4, D6, D8 etc from reporting alltogether, but that would possibly break code relying on these.
The Arduino Leonardo has 12 Analog pins. But A6 - A11 pins (D24 - D29) are actually other pins that are being re-used (D4, D6, D8, D9, D10, and D12). it means D4 and D24 are the same physical pin.
Now, StandardFirmata (and probably others) threats those pins as separate pins while Arduino threats them as the same. So, during systemResetCallback, those physical pins are actually initialized twice in Firmata. Once as Digital output (e.g. D4) and then later as analog pin (A6 - D24). This leads to an inconsistency between Firmata and the board's state:
Firmata state (internal state, and reported to the client application):
D4 : OUTPUT
D24 (A6): ANALOG INPUT
Arduino (Board) state:
D4 - D24 - A6: ANALOG INPUT
As Firmata thinks that D4 is OUTPUT while it's actually ANALOG INPUT, a digitalWrite (from SET_DIGITAL_PIN_VALUE or DIGITAL_MESSAGE) on D4 will not do anything.
I don't know if other Arduino boards also remap existing pins or if it's specific to Leonardo. So I'm not sure what's the best way to fix this issue.
Work around: By not using pins D4, D6, D8, D9, D10, and D12, but their equivalent pin number (D24 - D29), Firmata and Arduino states are consistent and work as expected.
The text was updated successfully, but these errors were encountered: