ggg

Dependencies:   mbed

Revision:
0:310fa9b8d43e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 31 10:13:50 2016 +0000
@@ -0,0 +1,36 @@
+# 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");
+            */
+        }
+    }
+}
\ No newline at end of file