![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
7 Segment disp
Revision 0:288c00e3c1ae, committed 2015-01-29
- Comitter:
- psahay
- Date:
- Thu Jan 29 22:45:45 2015 +0000
- Commit message:
- Lab1
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 29 22:45:45 2015 +0000 @@ -0,0 +1,58 @@ +#include "mbed.h" + +InterruptIn pound(p25); +DigitalOut myled(LED1); +DigitalOut dot(p20); +DigitalOut dash(p19); + +Timer t1; +Timer t2; + +Serial pc(USBTX, USBRX); + +void pPress () { + t2.stop(); + if(t2.read_ms() > 400) { + dot = 1; + dash= 1; + pc.printf(" "); + } + t1.start(); + myled = 1; + + } +void pRelease() { + t1.stop(); + if(t1.read_ms() > 30 && t1.read_ms() <= 200){ + dot = 0; + pc.printf("."); + } + else if (t1.read_ms() > 200) { + //dash= 0; + pc.printf("-"); + } + wait(0.1); + t1.reset(); + t2.reset(); + + dot = 1; + //dash = 1; + myled = 0; + + t2.start(); + } +int main() { + dot=1; + dash=1; + myled = 0; + pound.rise(&pPress); + pound.fall(&pRelease); + t2.start(); + while(1) { + if(t1.read_ms()> 200) { + dash = 0; + wait(0.1); + dash = 1; + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 29 22:45:45 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file