control simple de motor paso a paso unipolar

Dependencies:   mbed

Revision:
0:414bd7c6b901
Child:
1:26c2fd1ea036
diff -r 000000000000 -r 414bd7c6b901 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 22 04:47:24 2012 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+BusOut myleds(LED1, LED2, LED3, LED4);
+BusOut motor(p10, p11, p12, p13);
+
+/* Step C0 C1 C2 C3
+     1  1  0  1  0
+     2  0  1  1  0
+     3  0  1  0  1
+     4  1  0  0  1
+     */
+int tiempo = 12000;
+int main() {
+    while(1) {
+        for (int s = 0; s < 120 ; s +=1) {
+        motor = (0xA);
+        wait_us(tiempo);
+        motor = (0x6);
+        wait_us(tiempo);
+        motor = (0x5);
+        wait_us(tiempo);
+        motor = (0x9);
+        wait_us(tiempo);
+        }
+        wait(2);
+        for (int s = 0; s < 120 ; s +=1) {
+        motor = (0x9);
+        wait_us(tiempo);
+        motor = (0x5);
+        wait_us(tiempo);
+        motor = (0x6);
+        wait_us(tiempo);
+        motor = (0xA);
+        wait_us(tiempo);
+        }
+        wait(2);
+   }
+}