haris spahic faris dzafic

Dependencies:   mbed sMotor

Files at this revision

API Documentation at this revision

Comitter:
tim007
Date:
Thu May 15 16:03:09 2014 +0000
Commit message:
lv9-zad2-tim007-grupa6

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
sMotor.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e05d02767558 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 15 16:03:09 2014 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+#include "sMotor.h"
+
+Serial pc(USBTX, USBRX);
+sMotor motor(dp13, dp11, dp10, dp9);
+
+int speed = 1200; 
+int numstep= 512; 
+bool start=false;
+
+int smjer=0; //0 - desno
+
+int main() {
+
+    pc.printf("1- pokreni/zaustavi \n\r");
+    pc.printf("2- promjeni smjer(0-desno,1-lijevo) \n\r");
+    pc.printf("3- postavljanje polozaja \n\r");
+    pc.printf("4- promjeni brzinu \n\r");
+ while (1) {
+        if(start) motor.step(numstep,smjer,speed);
+        char c = pc.getc();
+        if (c == '1' && start == false ) start = true; 
+        else if(c == '1' && start == true) start = false; 
+        else if(c == '2' && smjer == 0)smjer = 1;
+        else if(c == '2' && smjer == 1) smjer = 0;
+        else if(c == '3'){
+            int ugao;
+            pc.printf("\n\r");
+            pc.printf("Postavi polozaj: \n\r");
+            pc.scanf("%d", &ugao);
+            numstep = int(512/360*(ugao%360));
+            motor.step(numstep,smjer,speed);
+            numstep = 512;
+           }
+        else if (c == '4') {
+                pc.printf("Nova brzina: \n\r");
+                pc.scanf("%d",&speed);
+            }
+        else continue;
+
+      }  
+}
\ No newline at end of file
diff -r 000000000000 -r e05d02767558 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 15 16:03:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
diff -r 000000000000 -r e05d02767558 sMotor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sMotor.lib	Thu May 15 16:03:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/XtaticO/code/sMotor/#4b3b9e047ce3