ytsuboi kappa

Dependencies:   mbed

Fork of A4988_sample by Yoshihiro TSUBOI

Revision:
0:b9c1a7c906f5
Child:
1:3f5ad896f93b
diff -r 000000000000 -r b9c1a7c906f5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Mar 22 15:41:45 2014 +0000
@@ -0,0 +1,47 @@
+// simple A4988 sample
+// jumper reset and sleep together
+// connect  VDD to mbed VOUT
+// connect  GND to mbed GND
+// connect  1A and 1B to stepper coil 1 (GREEN and BLACK wire)
+// connect 2A and 2B to stepper coil 2 (BLUE and RED wire)
+// connect VMOT to power source (to AC adapter)
+// connect GRD to power source (to AC adapter)
+// connect STEP to mbed p22
+// connect DIR to mbed p21
+
+#include "mbed.h"
+
+DigitalOut A4988STEP(p22);
+DigitalOut A4988DIR(p21);
+int a=0;
+
+int main() {
+    A4988DIR = 0;
+    A4988STEP = 0;
+
+    while(1) {
+      if (a <  200)  //sweep 200 step in dir 1
+       {
+        a++;
+        A4988STEP = 1;
+        wait(0.008);
+        A4988STEP = 0;
+        wait(0.008);
+       }
+      else 
+       {
+        A4988DIR = 1;
+        a++;
+        A4988STEP = 1;
+        wait(0.008);
+        A4988STEP = 0;
+        wait(0.008);
+        
+        if (a>400)    //sweep 200 in dir 2
+         {
+          a = 0;
+        A4988DIR = 0;
+         }
+        }
+    }
+}