Internal Pullup Example

Dependencies:   mbed

main.cpp

Committer:
ogata_lab
Date:
2013-05-29
Revision:
0:aa7758dc2f59

File content as of revision 0:aa7758dc2f59:

#include "mbed.h"

DigitalOut led1(LED1);

// Pin name can also be used to initialize DigitalIn and DigitalOut.
DigitalIn sw1(p20);

int main() {
    // Inner pull up on
    sw1.mode(PullUp);
        
    while(1) {
        if (sw1 == 0) { // If Pushed
           led1 = 1;
        } else { // Else (if not pushed)
           led1 = 0;
        }
    }
}