-
Notifications
You must be signed in to change notification settings - Fork 517
Description
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.