Program for controlling stepper motors with threads.
Fork of L298N_Stepper_4wire_example by
main.cpp
- Committer:
- rlanghbv
- Date:
- 2016-02-29
- Revision:
- 0:bd78e433db61
- Child:
- 1:a3287196a9b3
File content as of revision 0:bd78e433db61:
#include "mbed.h" DigitalOut IN1(D3); DigitalOut IN2(D4); DigitalOut IN3(D5); DigitalOut IN4(D6); DigitalIn SW(USER_BUTTON); void step4Right() { IN1=0; IN2=1; IN3=0; IN4=1; wait_us(1000); IN1=0; IN2=1; IN3=1; IN4=0; wait_us(1000); IN1=1; IN2=0; IN3=1; IN4=0; wait_us(1000); IN1=1; IN2=0; IN3=0; IN4=1; wait_us(1000); } void step4Left() { IN1=1; IN2=0; IN3=0; IN4=1; wait_us(1000); IN1=1; IN2=0; IN3=1; IN4=0; wait_us(1000); IN1=0; IN2=1; IN3=1; IN4=0; wait_us(1000); IN1=0; IN2=1; IN3=0; IN4=1; wait_us(1000); } int main() { while (true) { if(SW==1) step4Left(); else step4Right(); } }