-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
analog pin paramter for analogRead not zero based #1766
Comments
It's not zero based for at least two variants of the AVR core: Edit: |
Thx for considering the suggestion. Keeping A0 at 17 will not be a problem if analogRead works with pin=0. |
An analysis has shown that the wifio board has some extras that need to be considered, especially A1 to A7 in addition to A0. Best I can think of would be to do it like we agreed for A0 and support access both absolute and zero based. There are no overlaps between absolute pin numbers and zero based pin numbers even with wifio so this should be possible. This issue blocks the integration of the ESP8266 into firmata/arduino (see firmata/arduino#278 (comment)). |
@jnsbyr this is now fixed in git version. |
Thanks, will let you know how it works. |
With the new version There are similar problems with the macros My suggestions:
#define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS)?1:0)
#define digitalPinHasPWM(p) (((p) < NUM_DIGITAL_PINS)?1:0)
#define digitalPinToInterrupt(p) (((p) < EXTERNAL_NUM_INTERRUPTS && ((p) < 6 || (p) > 11))?1:0)
#define digitalPinHasPWM(p) (((p) < NUM_DIGITAL_PINS && ((p) < 6 || (p) > 11))?1:0) EDIT: |
@igrr |
@jnsbyr Thanks! It will get closed (automatically) once we deploy the new release (2.2.0). |
Basic Infos
Hardware
Hardware: ESP8266 - all boards
Core Version: 2.1.0
Description
The analog pin parameter for analogRead() is currently not zero based but absolute (A0 = 17) in contrast to the standard Arduino library implementation (see https://www.arduino.cc/en/Reference/AnalogRead). This makes ports of existing projects (e.g. https://github.com/firmata/arduino) harder.
Possible Solution
The text was updated successfully, but these errors were encountered: