Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:aabf665a689a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Sep 22 03:06:41 2019 +0000 @@ -0,0 +1,65 @@ +//Programa que hace la lectura del pin analogico, muebe el motor a pasos bipolar +// y tambien envia el numero de ciclos por el puerto serial para la interfaz grafica en visual Studio +#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; +AnalogIn a1(A0); + + +int main() +{ + + int x=0; + int y=0; + int v=0; + + +while(1){ + + + y=270*a1.read(); + + pc.printf("%d\n",y); + + wait(0.05); + if(x<y) + { + for(x=v;x<y;x++) + { + y=270*a1.read(); + pc.printf("%d\n",y); + + wait(0.02); + M1=pos1[i]; + wait(0.01); + i++; + if(i==4) + i=0; + } + v=x; + } + wait(0.01); + if(x>y) + { + for(x=v;x>y;x--) + { + y=270*a1.read(); + pc.printf("%d\n",y); + + wait(0.02); + M1=pos2[u]; + wait(0.01); + u++; + if(u==4) + u=0; + } + v=x; + } + + + } + } \ No newline at end of file