PCシリアルサンプルプログラム mbedセミナー演習2ex

Dependencies:   mbed

main.cpp

Committer:
jksoft
Date:
2011-08-26
Revision:
0:c886b74709da

File content as of revision 0:c886b74709da:

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx
DigitalIn sw(p5);

int main() {
    int old = sw;
    int count = 0;
    
    sw.mode(PullUp);
    
    pc.printf("Counter!");
    
    while(1) {
        if((sw == 0)&&(old == 1))
        {
            count++;
            printf("%d\r\n",count);
            wait(0.2);
        }
        old = sw;
    }
}