Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:264924f590d2
- Child:
- 1:ef8b9b9fe97d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Dec 19 07:03:16 2017 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" + +InterruptIn button(USER_BUTTON); +Serial pc(USBTX, USBRX); //TX, RX +DigitalOut led(LED1); + +double delay = 0.5; // 500 ms +int tamp = 0; //เอามาดูค่าที่ใช้ทดลองกดปุ่ม + +void pressed() +{ + delay = 0.1; // 100 ms + tamp = tamp + 1 ; +} + +void released() +{ + delay = 0.5; // 500 ms + pc.printf("tamp stable = %d " , tamp); +} + +int main() +{ + // Assign functions to button + button.fall(&pressed); + button.rise(&released); + + while (1) { + led = !led; + pc.printf("%d" , tamp); + wait(delay); + } +}