ggg

Dependencies:   mbed

Committer:
hellebrand
Date:
Thu Mar 31 10:13:50 2016 +0000
Revision:
0:310fa9b8d43e
hm, hm

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hellebrand 0:310fa9b8d43e 1 # include "mbed.h"
hellebrand 0:310fa9b8d43e 2
hellebrand 0:310fa9b8d43e 3 DigitalOut pipak (D12);
hellebrand 0:310fa9b8d43e 4 DigitalIn Tlac_1 (D10);
hellebrand 0:310fa9b8d43e 5 Serial comp(SERIAL_TX, SERIAL_RX);
hellebrand 0:310fa9b8d43e 6
hellebrand 0:310fa9b8d43e 7 int main () {
hellebrand 0:310fa9b8d43e 8 comp.baud(9600);
hellebrand 0:310fa9b8d43e 9 float fregvence, perioda, cas;
hellebrand 0:310fa9b8d43e 10 bool cudl, cudl_pred, pipej, smer;
hellebrand 0:310fa9b8d43e 11 fregvence = 1000;
hellebrand 0:310fa9b8d43e 12 while (1) {
hellebrand 0:310fa9b8d43e 13 cudl_pred = cudl;
hellebrand 0:310fa9b8d43e 14 cudl = Tlac_1;
hellebrand 0:310fa9b8d43e 15 perioda = 1 / fregvence;
hellebrand 0:310fa9b8d43e 16 cas = perioda / 2;
hellebrand 0:310fa9b8d43e 17 if((cudl==1)&&(cudl_pred==0)) pipej = !pipej;
hellebrand 0:310fa9b8d43e 18 if(pipej == 1) {
hellebrand 0:310fa9b8d43e 19 for(int i=0;i<(fregvence / 25);i++) {
hellebrand 0:310fa9b8d43e 20 pipak = 1; // LED zapnuta
hellebrand 0:310fa9b8d43e 21 wait (cas) ; // 200 ms
hellebrand 0:310fa9b8d43e 22 pipak = 0; // LED vypnuta
hellebrand 0:310fa9b8d43e 23 wait (cas) ; // 1 sec
hellebrand 0:310fa9b8d43e 24 }
hellebrand 0:310fa9b8d43e 25 if (smer == 1) fregvence = fregvence * 1.1;
hellebrand 0:310fa9b8d43e 26 if (smer == 0) fregvence = fregvence / 1.1;
hellebrand 0:310fa9b8d43e 27 if (fregvence > 6000) smer = 0;
hellebrand 0:310fa9b8d43e 28 if (fregvence < 300) smer = 1;
hellebrand 0:310fa9b8d43e 29 /* comp.printf("cas: %.8f",cas);
hellebrand 0:310fa9b8d43e 30 comp.printf("\t perioda: %.8f",perioda);
hellebrand 0:310fa9b8d43e 31 comp.printf("\t fregvence: %0.1f",fregvence);
hellebrand 0:310fa9b8d43e 32 comp.printf("\n\r");
hellebrand 0:310fa9b8d43e 33 */
hellebrand 0:310fa9b8d43e 34 }
hellebrand 0:310fa9b8d43e 35 }
hellebrand 0:310fa9b8d43e 36 }