tim003 tim003
/
LV9_Zadatak2_Grupa6_Tim003
Armin Klacar Ensar Muratovic
Revision 0:1e96a516f571, committed 2014-05-15
- Comitter:
- tim003
- Date:
- Thu May 15 16:03:48 2014 +0000
- Commit message:
- LV9-Zadatak2-Grupa6-Tim003
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 1e96a516f571 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 15 16:03:48 2014 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); +Ticker run; +BusOut motor(dp13, dp11, dp10, dp9); //IN1, IN2, IN3, IN4 +int anticlockwise[8] = {1, 3, 2, 6, 4, 12, 8, 9}; +int clockwise[8] = {9, 8, 12, 4, 6, 2, 3, 1}; +int speed = 1200; +bool startstop = false; +bool direction = true; +int stepen = 360; +double x = 0.703125; +void spin(){ + switch (direction) { + case true: {for (int i = 0; i < 8; i++) {motor = clockwise[i];wait_us(speed);}} break; + case false: {for (int i = 0; i < 8; i++) {motor = anticlockwise[i];wait_us(speed);}} break; + } + } + +int main() +{ + + while (1){ + + +if (pc.readable()){ + char c = pc.getc(); + + if(c=='A'){ + pc.scanf ("%d",&stepen); + for (int i=0; i<(stepen/x);i++) spin(); + + } + else if (c=='B')direction = !direction; + else if(c=='C') pc.scanf ("%d",&speed); + else if (c=='D') startstop=!startstop; +} + + if (startstop) spin(); + + + + } +} \ No newline at end of file
diff -r 000000000000 -r 1e96a516f571 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 15 16:03:48 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file