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.
Revision 0:056c055636d2, committed 2021-11-11
- Comitter:
- cspista
- Date:
- Thu Nov 11 14:28:14 2021 +0000
- Commit message:
- Final version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 056c055636d2 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 11 14:28:14 2021 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +DigitalIn mybutton(BUTTON1,PullUp); // Pushbutton input (PC_13) +InterruptIn button(BUTTON1); // Pusbutton interrupt +Serial pc(USBTX,USBRX); // UART0 via OpenSDA +volatile uint16_t counts; // counter variable + +void button_pressed() { + counts++; // counts button presses +} + +int main() { + pc.baud(115200); // set baudrate for UART + button.mode(PullUp); // Enable internal pullup + button.fall(&button_pressed); // Attach function to falling edge + while (true) { + counts = 0; // Clear counter + pc.printf("Press & release switch... \r\n"); + while (mybutton); // Wait for button press + wait_ms(20); // Debounce delay + while (!mybutton); // Wait for button release + wait_ms(20); // Debounce delay + pc.printf("Button pressed %d times\r\n",counts); + } +} \ No newline at end of file
diff -r 000000000000 -r 056c055636d2 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 11 14:28:14 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file