-
-
Notifications
You must be signed in to change notification settings - Fork 212
analogRead()
does not reset pin properly after previous pinMode()
#829
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
Comments
Hello @dhalbert , i modified your text and it seems to be working :
the problem is still the same with touchsceen... but i'm wondering if it's not just about a pins definition problem ? |
@MattGlobal In the example you gave, there is no |
Here is the impl: ArduinoCore-mbed/cores/arduino/wiring_analog.cpp Lines 101 to 121 in 68fbece
The first time through, a new mbed::AnalogIn object is created. That's reused on subsequent calls.
A workaround might be to call |
BSP: Arduino MBed OS Giga boards v4.0.10
Board: Giga R1
Arduino IDE: 2.2.1
Sample sketch:
On my test setup, this prints:
I would expect it to print
744
or close to that twice.Once the pin is used in the
pinMode()
, it appears to be pulled low.By comparison, the same sketch on an Arduino Uno prints (with the 220K resistor connected to 5V):
The use case is a resistive touch screen driver (https://github.com/adafruit/Adafruit_TouchScreen) which flips pins back and forth between digital input/output and analog input modes to read X/Y resistance values.
This is reminiscent of (though order is different) to #328 and arduino/ArduinoCore-renesas#58
The text was updated successfully, but these errors were encountered: