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

Floating pin reading as high (DAL has pull downs) #67

Closed
microbit-carlos opened this issue Jan 19, 2021 · 2 comments
Closed

Floating pin reading as high (DAL has pull downs) #67

microbit-carlos opened this issue Jan 19, 2021 · 2 comments

Comments

@microbit-carlos
Copy link
Collaborator

microbit-carlos commented Jan 19, 2021

This programme in V1 DAL always reads the pin a floating pin as "low", until a jumper cable is used to connect it to the 3V pin.

#include "MicroBit.h"

MicroBit uBit;

int  main() {
    uBit.init();
    // uBit.io.P1.setPull(PullMode::Down);
    while (1) {
        if (uBit.io.P1.getDigitalValue() == 1) {
            uBit.display.printChar('H');
            uBit.sleep(400);
        } else {
            uBit.display.printChar('L');
            uBit.sleep(400);
        }
    }
}

The sleep is not required, it also shows that in V2 CODAL the first reading of the pin is always 0, as on reset it always it shows the L on the display once and then stays H.

Uncommenting the pull down matches the V1 DAL behaviour.

Tested P0,P1, P12, and P16, so I assume this is probably true for all io.

@martinwork
Copy link
Collaborator

Related: #17

@microbit-carlos
Copy link
Collaborator Author

Thanks Martin, didn't see that issue when I opened this. As it is essentially the same I'll close this one to concentrate the conversation over there.

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

No branches or pull requests

3 participants