![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
PCシリアルサンプルプログラム mbedセミナー演習2ex
Diff: main.cpp
- Revision:
- 0:c886b74709da
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Aug 26 15:37:17 2011 +0000 @@ -0,0 +1,23 @@ +#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; + } +}