紹輔 伍
/
A4988_sample
ytsuboi kappa
Fork of A4988_sample by
main.cpp
- Committer:
- ytsuboi
- Date:
- 2014-03-22
- Revision:
- 0:b9c1a7c906f5
- Child:
- 1:3f5ad896f93b
File content as of revision 0:b9c1a7c906f5:
// 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; } } } }