Nedim Hozić Selma Tucak

Dependencies:   mbed sMotor

Files at this revision

API Documentation at this revision

Comitter:
tim003
Date:
Thu May 15 18:15:16 2014 +0000
Commit message:
PAI-LV9-Zadatak2

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 15 18:15:16 2014 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+#include "sMotor.h"
+
+Serial pc(USBTX, USBRX);
+sMotor motor(dp13, dp11, dp10, dp9);
+
+int step_speed = 0;
+int numstep = 512;
+int direction = 0;
+int main() {
+    pc.printf("O - Postavljanje osovine u proizvoljan polozaj. \n");
+    pc.printf("P - Promjena smjera okretanja. \n");
+    pc.printf("B - Promjena brzine okretanja. \n");
+    pc.printf("K - Pokreni motor. \n");
+    pc.printf("S - Zustavi motor. \n");
+    pc.printf("Trenutna brzina je %d", step_speed);
+    step_speed=1200;
+    while(1) {
+        if(pc.readable()) 
+        {
+            char a = pc.getc();
+        if(a=='O')
+        {
+            int ugao;
+            pc.printf("\nUnesi ugao: ");
+            pc.scanf("%d", &ugao);
+            numstep = (ugao/360.00)*512;
+            motor.step(numstep,direction,step_speed);
+        }
+        if(a=='P')
+        {
+            numstep = 512;
+            if(direction==0)
+            {
+            motor.anticlockwise();
+            direction = 1;
+            }
+            else
+            {
+                motor.clockwise();
+                direction = 0;
+            }
+            motor.step(numstep,direction,step_speed);
+        }
+        if(a=='B')
+        {
+            pc.printf("Trenutna brzina je %d, unesite novu: ");
+            pc.scanf("%d", &step_speed);
+            motor.step(numstep,direction,step_speed);
+        }
+        if(a=='K')
+        {   
+            if(step_speed==0)
+            step_speed = 1200;
+            motor.step(numstep,direction,step_speed);
+        }
+        if(a=='S')
+        {
+            motor.step(0,direction,step_speed);
+        }
+    }
+}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 15 18:15:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sMotor.lib	Thu May 15 18:15:16 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/XtaticO/code/sMotor/#4b3b9e047ce3