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

digitalRead()/analogRead() interference #1006

merged 2 commits into from Jun 10, 2016


Copy link

commented May 22, 2016

Fixes #993

  • Saves PinMode in PIN_MAP[pin].user_property instead of a single global variable
  • Fixes ADC PinMode configuration
  • Fixes DAC PinMode configuration (affected by the same issue as ADC pins described in #993 under certain conditions)

Relevant tests:

  • wiring/no_fixture GPIO_AnalogReadWorksMixedWithDigitalRead
  • wiring/adc_dac DAC_AnalogWriteWorksMixedWithDigitalRead


  • Contributor has signed CLA
  • Problem and Solution clearly stated
  • Code peer reviewed
  • API tests compiled
  • Run unit/integration/application tests on device
  • Add documentation (to docs master)

Since 0.5.3 Note: you do not need to set the pinMode() with analogRead(). The pinMode() is automatically set to AN_INPUT any time analogRead() is called for a particular analog pin, if that pin is set to a pinMode other than AN_INPUT. If you explicitly set a pin to INPUT, INPUT_PULLUP, INPUT_PULLDOWN or OUTPUT before using analogRead(), it will switch it back to AN_INPUT before taking the reading. If you use digitalRead() afterwards, it will automatically switch the pinMode back to whatever you originally explicitly set it to.

  • Add to after merging (add links to docs and issues)
@avtolstoy avtolstoy referenced this pull request May 22, 2016
3 of 3 tasks complete

@m-mcgowan m-mcgowan added this to the 0.6.x milestone Jun 10, 2016

@m-mcgowan m-mcgowan self-assigned this Jun 10, 2016

avtolstoy and others added 2 commits May 22, 2016

@m-mcgowan m-mcgowan force-pushed the feature/save-pinmode branch from b403fd6 to 14a0086 Jun 10, 2016

@m-mcgowan m-mcgowan merged commit 79995f3 into develop Jun 10, 2016

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
continuous-integration/travis-ci/push The Travis CI build is in progress

This comment has been minimized.

Copy link

commented Jun 10, 2016

Tested on the Core.

@technobly technobly deleted the feature/save-pinmode branch Oct 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.