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
main.cpp
00001 //Programa que hace la lectura del pin analogico, muebe el motor a pasos bipolar 00002 // y tambien envia el numero de ciclos por el puerto serial para la interfaz grafica en visual Studio 00003 #include "mbed.h" 00004 00005 BusOut M1(D2,D3,D4,D5); 00006 Serial pc(USBTX,USBRX); 00007 char pos1[4]={0x05,0x06,0x0A,0x09}; 00008 char pos2[4]={0x0A,0x06,0x05,0x09}; 00009 int i=0,u=0; 00010 AnalogIn a1(A0); 00011 00012 00013 int main() 00014 { 00015 00016 int x=0; 00017 int y=0; 00018 int v=0; 00019 00020 00021 while(1){ 00022 00023 00024 y=270*a1.read(); 00025 00026 pc.printf("%d\n",y); 00027 00028 wait(0.05); 00029 if(x<y) 00030 { 00031 for(x=v;x<y;x++) 00032 { 00033 y=270*a1.read(); 00034 pc.printf("%d\n",y); 00035 00036 wait(0.02); 00037 M1=pos1[i]; 00038 wait(0.01); 00039 i++; 00040 if(i==4) 00041 i=0; 00042 } 00043 v=x; 00044 } 00045 wait(0.01); 00046 if(x>y) 00047 { 00048 for(x=v;x>y;x--) 00049 { 00050 y=270*a1.read(); 00051 pc.printf("%d\n",y); 00052 00053 wait(0.02); 00054 M1=pos2[u]; 00055 wait(0.01); 00056 u++; 00057 if(u==4) 00058 u=0; 00059 } 00060 v=x; 00061 } 00062 00063 00064 } 00065 }
Generated on Thu Aug 25 2022 23:50:52 by
1.7.2