Ilvana Brankovic Hamdija Sinanovic

Dependencies:   mbed sMotor

Files at this revision

API Documentation at this revision

Comitter:
tim004
Date:
Thu May 15 13:58:49 2014 +0000
Commit message:
lv9_Grupa5_zad2_Tim004;

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 2251773534ef main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 15 13:58:49 2014 +0000
@@ -0,0 +1,74 @@
+#include "mbed.h"
+#include "sMotor.h"
+
+Serial pc(USBTX, USBRX);
+sMotor motor(dp9, dp10, dp11, dp13);
+
+char znak;
+int stani=0;
+int brzina_motora=1200;
+int ugao=512;
+int brojac=0;
+int smjer=0;// smjer kazaljke na satu
+int vrti=0;
+
+int main() {
+    pc.printf("Unesite 1 za proizvoljan polozaj.");
+       pc.printf("Unesite 2 za promjenu smjera kretanja");
+       pc.printf("Unesite 3 za promjenu brzine kretanja");
+       pc.printf("Unesite 4 da zaustavite/pokrenete motor");
+    while(1) {
+       //smjer 0 kazaljka na satu, 1 suprotno
+       if(vrti==0)
+       motor.step(ugao,smjer,brzina_motora);//smjer kazaljke na satu
+       /*if(vrti==1)
+       motor.step(stani,smjer,brzina_motora);*/
+       znak=pc.getc();
+       if(znak=='4')
+       {
+             brojac++;
+           if(brojac%2==1)
+           {
+            //if(vrti==0)motor.step(stani,smjer,brzina_motora);
+            vrti=1; motor.step(stani,smjer,brzina_motora);
+            
+           }
+           else
+           {
+               //if(vrti==0)motor.step(ugao,smjer,brzina_motora);
+               vrti=0;
+           }
+           
+        }
+        if(znak=='3')
+        {
+            pc.printf("Unesi novu brzinu");
+            pc.scanf("%d",&brzina_motora);
+            if(vrti==0)motor.step(ugao,smjer,brzina_motora);
+            
+        }
+        if(znak=='2')
+        {
+            if(smjer==0)
+            {
+                smjer=1;
+            }
+            else
+            {
+                smjer=0;
+            }
+            if(vrti==0)motor.step(ugao,smjer,brzina_motora);
+        }
+        if(znak=='1')
+        {
+            pc.printf("Unesite novi ugao");
+            pc.scanf("%d",&ugao);
+            if(ugao>0 && ugao<360)
+            {
+            int n=360/ugao;
+            if(vrti==0)motor.step(int(ugao/n),smjer,brzina_motora);
+            }
+        }
+        
+    }
+}
diff -r 000000000000 -r 2251773534ef mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 15 13:58:49 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 2251773534ef sMotor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sMotor.lib	Thu May 15 13:58:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/XtaticO/code/sMotor/#4b3b9e047ce3