motor bipolar ctrl visual st
Dependencies: mbed
Revision 0:019a33f5a47c, committed 2019-11-19
- Comitter:
- Javierdf
- Date:
- Tue Nov 19 05:05:57 2019 +0000
- Commit message:
- motor bipolar visual
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 019a33f5a47c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 19 05:05:57 2019 +0000 @@ -0,0 +1,50 @@ +#include "mbed.h" + +BusOut M1(D2,D3,D4,D5); +Serial pc(USBTX, USBRX); +char pos1[4]={0x05,0x06,0x0A,0x09}; +char pos2[4]={0x0A,0x06,0x05,0x09}; +int i=0,u=0; + +int main() +{ + + int x=0; + int y=0; + int v=0; + +while(1){ + + y=pc.getc(); + + if(x<=y) + { + for(x=v;x<=y;x++) + { + y=pc.getc(); + + M1=pos1[i]; + wait(0.005); + i++; + if(i==4) + i=0; + } + v=x; + } + + if(x>=y) + { + for(x=v;x>=y;x--) + { + y=pc.getc(); + + M1=pos2[u]; + wait(0.005); + u++; + if(u==4) + u=0; + } + v=x; + } + } + }
diff -r 000000000000 -r 019a33f5a47c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 19 05:05:57 2019 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec \ No newline at end of file