Internal Pull Up

http://mbed.org/users/4180_1/notebook/pushbuttons/

Mbed has special inputs that can be programmed to provide an internal pullup resistor and eliminate the need to add an external resistor when hooking up pushbuttons and switches. To use it, on a DigitalIn pin set the mode to pullup with pin.mode(PullUp);, and leave out the external resistor. The switch is then connected to the input pin and the other switch connection is tied to ground. While the focus here is on pushbuttons, the same techniques will apply to the use of other switches such as the individual switches found in a DIP switch.

Example for digital Out

#include "mbed.h"
 
DigitalOut myled(LED1);
DigitalOut Ctrl(p8);
 
int main() {
    while(1) {
        Ctrl = 1;
        myled = 1;
        wait(2);
        Ctrl = 0;
        myled = 0;
        wait(2);
    }
}
 


4 comments on Internal Pull Up:

02 Jul 2014

Will this work for I2C as well ?

20 Sep 2015

Bad example. There's no digitalin or pin.mode statement.

20 Jul 2016

Would be really helpful if someone could add a digitalin example with pullup

05 Oct 2016

The above is invalid. Below is the basic example that the above was trying to be:

#include "mbed.h"


DigitalOut myled(LED1);
DigitalIn Ctrl(p8);
int main() {
    Ctrl.mode(PullUp);
    while(1) {
        myled = pb;
    }
}

Please log in to post comments.