![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Amer Ratković Emina Muharemović
Revision 0:3be2599834d0, committed 2014-05-15
- Comitter:
- tim008
- Date:
- Thu May 15 13:58:57 2014 +0000
- Commit message:
- LV9_Grupa5_Tim8_Zadatak2
Changed in this revision
diff -r 000000000000 -r 3be2599834d0 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 15 13:58:57 2014 +0000 @@ -0,0 +1,97 @@ +#include "mbed.h" +#include "sMotor.h" + + +Serial pc(USBTX, USBRX); +sMotor motor(dp9, dp10, dp11, dp13); // creates new stepper motor: IN1, IN2, IN3, IN4 +Ticker t; +int step_speed = 1200 ; // set default motor speed +float numstep = 512 ; // defines full turn of 360 degree +int speed=888; +bool radi=true; +int smjer=1; +void meni() +{ + pc.printf("A - Postavi osovinu motora (0-360 stepeni) \n"); + pc.printf("S - Promjeni brzinu kretanja \n"); + pc.printf("D - Promjeni smjer kretanja \n"); + pc.printf("F - Pokreni/zaustavi motor \n"); +} + +void pali_gasi() +{ + if(radi) + { + motor.step(numstep,smjer,speed); + pc.printf("Motor je upaljen.\n"); + + } + else + { + motor.step(numstep,smjer,0); + pc.printf("Motor je ugasen.\n"); + + } +} + +void smjerovi() +{ + motor.step(numstep,smjer,speed); + +} + +int main() +{ + while (1) + { + + meni(); + + if(radi==true) + while(pc.getc()!='F') motor.step(numstep,smjer,speed); + radi=!radi; + + meni(); + char a; + a=pc.getc(); + if(a=='A') + { + int ugao; + pc.printf("\nNavedite ugao pomjeranja motora: \n"); + pc.scanf("%d", &ugao); + if ( ugao > 0 ) + motor.step(numstep / 360.0 * (ugao % 360), smjer, speed); + else + motor.step(numstep / 360.0 * (ugao % 360), 1 - smjer, speed); + } + if(a=='S') + { + pc.printf("\nTrenutna brzina: %d\n", speed); + pc.printf("\nNova brzina: \n"); + pc.scanf("%d",&speed); + motor.step(numstep,smjer,speed); + + } + if(a=='D') + { + if (smjer==0) + smjer=1; + else + smjer=0; + smjerovi(); + pc.printf("\nPromjena smjera. \n"); + + } + + if(a=='F') + { + radi=!radi; + pali_gasi(); + } + + + } + + +} +
diff -r 000000000000 -r 3be2599834d0 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 15 13:58:57 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 3be2599834d0 sMotor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sMotor.lib Thu May 15 13:58:57 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/XtaticO/code/sMotor/#4b3b9e047ce3