7 Segment disp

Dependencies:   mbed

main.cpp

Committer:
psahay
Date:
2015-01-29
Revision:
0:288c00e3c1ae

File content as of revision 0:288c00e3c1ae:

#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;
            }
    }
}