Pranav Sahay
/
Part4
7 Segment disp
Diff: main.cpp
- Revision:
- 0:288c00e3c1ae
--- /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