Digital In pin configuration

16 Mar 2011

Hi,

I would like to test use the digital in function to trigger the input signal (0,1).Example: if i want to install push-On switch to simulate the trigger function,1 pin connect to the Mbed pin5 and another pin should connect to which Mbed pin?sorry, i am newbie..Thanks for help

Cheers,

Charles

16 Mar 2011

Thanks,i fixed it.

19 Mar 2011

You probably wanted to attach the other pin to the 3.3V Vout. It sounds like you got it figured out, but I'll include some info just in case.

You might be interested in learning about pullup and pulldown resistors. By default the mbed is set to use an internal pulldown resistor, which will make the voltage go to zero when your push-switch is turned off.

If you wanted, you could connect the other pin of your switch to the ground instead and change the pin to pullup mode using the built-in mode function.

The code using a pullup resistor should look something like this:

#include "mbed.h"

DigitalIn myInputPin(p5);

int main() {
    myInputPin.mode(PullUp);  //set the mbed to use a pullup resistor
    while(1) {        
        if(myInputPin.read()==1) {    //a shorter way to write this is:    if(myInputPin){
            //insert code to do something if the input value is 1.
        }
    }
}
05 Apr 2011

Thanks.Jimmy

01 Jun 2011

Hi,

Is there a simple way to set an input pin mode (PullUp, PullDown, PullNone, or OpenDrain) without using the DigitalIn class? Reason for asking is that I am using the Serial class and I would like to pull up the receive pin without using an external resistor. Using the DigitalIn class then mode(PullUp) function on the same pin seems to stop the Serial working.

Thanks, Peter

27 Sep 2015

Hi, we are using the arduino code on mbed device, What the pin mode and digitalWrite equivalent command ? Tks Alexandre

24 Oct 2016

Alexandre Bisaggio wrote:

Hi, we are using the arduino code on mbed device, What the pin mode and digitalWrite equivalent command ? Tks Alexandre

pin = 1; or pin = 0;