Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent state for additional analog pins (A6 - A11) on Arduino Leonardo #486

Open
oliviercoma opened this issue Dec 18, 2021 · 1 comment

Comments

@oliviercoma
Copy link

oliviercoma commented Dec 18, 2021

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.

@pgrawehr
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants