DigitalIn and PullUp resistors

30 Mar 2010 . Edited: 30 Mar 2010

Hi!

In the handbooks says that by default the Pull-Up resistors are enable, when using the DigitalIn function.

I thing that it is not true! Using a very simple code I realize that the only possible way for the mbed to read a push button is when I put an external pull up!

30 Mar 2010

Hi Ioannis,

This code seems to work perfectly for me without any external pull ups.

#include "mbed.h"

DigitalOut myLed(LED1);
DigitalIn mySwitch(p21);

int main() 
{
    mySwitch.mode(PullUp);
    
    while(1) 
    {
        if(!mySwitch)       //Detect Switch Press
        {
            myLed=~myLed;   //Light LED
            wait(0.03);     //Debounce
            while(!mySwitch);   //Wait for Key release                              
        }
    }
}
Haven't checked if the pull ups are there by default, but the mode() seems to work fine.

 

Regards,

Devesh

30 Mar 2010 . Edited: 30 Mar 2010

Hi Devesh!!!

The mode works perfectly , I have tested before!

I just try to say that there is a mistake in the handbook section. It says that the pull up resistor is enabled by default but it is not like that. You have to use the *.mode() in the software of an external pull up.