ggg

Dependencies:   mbed

main.cpp

Committer:
hellebrand
Date:
2016-03-31
Revision:
0:310fa9b8d43e

File content as of revision 0:310fa9b8d43e:

# include "mbed.h"

DigitalOut pipak (D12);
DigitalIn Tlac_1 (D10);
Serial comp(SERIAL_TX, SERIAL_RX);

int main () {
    comp.baud(9600);
    float fregvence, perioda, cas;
    bool cudl, cudl_pred, pipej, smer;
    fregvence = 1000;
    while (1) {
        cudl_pred = cudl;
        cudl = Tlac_1;
        perioda = 1 / fregvence;
        cas = perioda / 2;
        if((cudl==1)&&(cudl_pred==0)) pipej = !pipej;
        if(pipej == 1) {
            for(int i=0;i<(fregvence / 25);i++) {
                pipak = 1; // LED zapnuta
                wait (cas) ; // 200 ms
                pipak = 0; // LED vypnuta
                wait (cas) ; // 1 sec
                }
            if (smer == 1) fregvence = fregvence * 1.1;
            if (smer == 0) fregvence = fregvence / 1.1;
            if (fregvence > 6000) smer = 0;
            if (fregvence < 300) smer = 1;
            /* comp.printf("cas: %.8f",cas);
            comp.printf("\t perioda: %.8f",perioda);
            comp.printf("\t fregvence: %0.1f",fregvence);
            comp.printf("\n\r");
            */
        }
    }
}