Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

digitalRead forces INPUT_PULLUP #30

Closed
@dcuartielles

Description

@dcuartielles

When creating a simple program to read a button with a pull-down resistor (10k) the input registers no voltage for as long as digitalRead is not called. Once digitalRead is issued, the pin seems to go into internal pull-up configuration, what makes the pin to be always up for the above-mentioned pull-down resistor.

Reproduce the error

  1. Investigating the issue requires using a multimeter and making a simple program:

void setup() {
pinMode(2, INPUT);
}

void loop() {
}

On the multimeter this reads: 0V

  1. Change the program to contain a digitalRead():

void setup() {
pinMode(2, INPUT);
}

void loop() {
digitalRead(2);
}

The multimeter goes then into 3v3 for that pin.

On the other hand, when checking into the way digitalRead is defined, we find that it returns:

return (PinStatus)mbed::DigitalIn(digitalPinToPinName(pin)).read();

(as seen at: https://github.com/arduino/ArduinoCore-nRF528x-mbedos/blob/master/cores/arduino/wiring_digital.cpp#L79)

This call to DigitalIn seems to be lacking PullNone, what could be the reason for this not to work. However, this requires a deeper revision, as just adding PullNone, would force it also in the case when we would like INPUT_PULLUP to be active.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions