PUSH BUTTONS & SWITCHES

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.

BASICALLY, you need a pullup resistor but mbed provides an INTERNAL ONE.

To use for DigitalIN, you gta setup as NAME-OF-PIN.mode(PullUp)

CODE:

LED=PB

let your led pin equal the push button bcuz when its pressed, it give an in of 0 (connected to ground & NO) so code reads that the input pin is 0 which code sees its equal to the output of the led which is also 0 so it should turn off.

https://os.mbed.com/users/4180_1/notebook/pushbuttons/


Please log in to post comments.