lv6

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
2016US_BenjaminRamic
Date:
Sun Jun 12 13:45:41 2016 +0000
Commit message:
lv6;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ed637ab95222 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 12 13:45:41 2016 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+#define dp23 P0_0
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+AnalogIn VRx(dp11);
+AnalogIn VRy(dp10);
+
+DigitalIn SW(dp9);
+Timer timer;
+
+int smijer = 0; // 1 - lijevo, 3 - gore, 2 - desno, 4 - dole, 5 - centar
+
+void usmjerenje(int noviSmijer)
+{
+        if(noviSmijer != smijer)
+        {
+        smijer = noviSmijer;
+        char text[300];
+        
+        if(smijer == 1)
+        {
+            sprintf(text, "lijevo\n");
+            pc.printf(text);
+        }else if(smijer == 2)
+        {
+            sprintf(text, "desno\n");
+            pc.printf(text);
+        }else if(smijer == 3)
+        {
+            sprintf(text, "gore\n");
+            pc.printf(text);
+        }else if(smijer == 4)
+        {
+            sprintf(text, "dole\n");
+            pc.printf(text);
+        }else if(smijer == 5)
+        {
+            sprintf(text, "centar\n");
+            pc.printf(text);
+        }
+    }
+    
+}
+
+int main() {
+    SW.mode(PullUp);
+    timer.start();
+    while (1)
+    {
+        if(VRx < 1.0/3.0) 
+            usmjerenje(1); // lijevo
+        else if(VRx < 2.0/3.0)
+            usmjerenje(5); // centar
+        else
+            usmjerenje(2); // desno
+            
+        if(VRy < 1.0/3.0) 
+            usmjerenje(3); // gore
+        else if(VRy < 2.0/3.0)
+            usmjerenje(5); // centar
+        else
+            usmjerenje(4); // dole        
+        wait(1);
+    }
+}
diff -r 000000000000 -r ed637ab95222 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jun 12 13:45:41 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f
\ No newline at end of file