motor bipolar pot variable

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Javierdf
Date:
Tue Nov 19 05:11:08 2019 +0000
Commit message:
motor bipolar pot var

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 19 05:11:08 2019 +0000
@@ -0,0 +1,54 @@
+// programa lectura de pin analogico infinito, para mover motor bipolar, en ambos sentidos
+#include "mbed.h"
+
+BusOut M1(D2,D3,D4,D5);
+char pos1[4]={0x05,0x06,0x0A,0x09};
+char pos2[4]={0x0A,0x06,0x05,0x09};
+int i=0,u=0;
+AnalogIn a1(A5);
+
+
+int main()  
+{
+    
+  int x=0;
+  int y=0;
+  int v=0;
+
+
+while(1){
+
+
+ y=200*a1.read();
+    wait(0.05);
+    if(x<y)
+    {
+        for(x=v;x<y;x++)
+        {
+            y=200*a1.read();
+            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=200*a1.read();
+            wait(0.02);
+         M1=pos2[u];
+         wait(0.01);
+         u++;
+         if(u==4)
+         u=0;
+            }
+         v=x; 
+        } 
+      }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 19 05:11:08 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file