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.
Fork of Keyboard_Interrupt by
main.cpp
- Committer:
- TakamiMa
- Date:
- 2015-06-02
- Revision:
- 2:1432d7c567f4
- Parent:
- 1:5440b3d7f435
File content as of revision 2:1432d7c567f4:
#include "mbed.h" #include <string.h> //If you type more than two numbers, then type Enter, you get connected number. Serial pc(SERIAL_TX, SERIAL_RX); char line[16]; int counter = 0; void my_Interrupt(){ char key; key = pc.getc(); int number = int(key-'0'); if( (number > 9 || number < 0) && key!='\r'){ pc.printf("you can type only number, you cannot use dot.\r\n"); goto skip; } if(key == '\r'){ pc.printf("Enter\r\n"); pc.printf("%d\r\n", atoi(line)); counter=0; goto skip; } line[counter] = key; counter++; pc.printf("Interrupted %c\r\n", key); skip: } int main() { memset(line, '\0', 16); pc.attach(my_Interrupt, Serial::RxIrq); while(1){} }