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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut myled(LED1); 00004 InterruptIn keytwo(p5); 00005 Timer t; 00006 Timeout to; 00007 bool spaceFlag = false; 00008 bool dotFlag = false; 00009 bool dashFlag = false; 00010 00011 void keynotpressed() { 00012 if(t.read_ms() != 0) { 00013 spaceFlag = true; 00014 } 00015 } 00016 00017 void keypressed() { 00018 t.reset(); 00019 t.start(); 00020 } 00021 00022 void keyreleased() { 00023 t.stop(); 00024 if(t.read_ms() > 30 & t.read_ms() < 200) { 00025 dotFlag = true; 00026 } 00027 else if(t.read_ms() > 200) { 00028 dashFlag = true; 00029 } 00030 t.reset(); 00031 to.attach(&keynotpressed,0.4); 00032 } 00033 00034 00035 00036 00037 int main() { 00038 //printf("Starting..."); 00039 keytwo.rise(&keypressed); 00040 keytwo.fall(&keyreleased); 00041 to.attach(&keynotpressed,0.4); 00042 while(1) { 00043 if(dotFlag){ 00044 printf("Dot"); 00045 dotFlag = false; 00046 } 00047 00048 if(dashFlag){ 00049 printf("Dash"); 00050 dashFlag = false; 00051 } 00052 00053 if(spaceFlag){ 00054 printf("Space"); 00055 spaceFlag = false; 00056 } 00057 } 00058 }
Generated on Sat Jul 16 2022 12:22:43 by
1.7.2