Very simple operation samples of unipolar stepper motor. This code has been made to help beginners to learn the stepper motor. The history of the code shows the how to generate pulses from very basic level.

Dependencies:   mbed

Revision:
5:28bbda0fe9b5
Parent:
0:6e775c640f78
Child:
6:11b35048d384
--- a/main.cpp	Sat Jan 11 01:23:30 2014 +0000
+++ b/main.cpp	Sat Jan 11 01:51:26 2014 +0000
@@ -1,40 +1,25 @@
 //  stepper motor operation sample (learn it step by step). 
 //  showing how to control a unipolar stepper motor by mbed digital output ports.
 //  
-//  version 0 : Check DigitalOut by LED
+//  version 0-2 : Check BusOut by LED
 
 #include "mbed.h"
 
-DigitalOut  motor_out0( LED1 );
-DigitalOut  motor_out1( LED2 );
-DigitalOut  motor_out2( LED3 );
-DigitalOut  motor_out3( LED4 );
+BusOut      motor_out( LED1, LED2, LED3, LED4 );
 
 int main() {
     while(1) {
         
-        motor_out0  = 1;
-        motor_out1  = 0;
-        motor_out2  = 0;
-        motor_out3  = 0;
+        motor_out   = 1;
         wait( 0.2 );
         
-        motor_out0  = 0;
-        motor_out1  = 1;
-        motor_out2  = 0;
-        motor_out3  = 0;
+        motor_out   = 2;
         wait( 0.2 );
         
-        motor_out0  = 0;
-        motor_out1  = 0;
-        motor_out2  = 1;
-        motor_out3  = 0;
+        motor_out   = 4;
         wait( 0.2 );
         
-        motor_out0  = 0;
-        motor_out1  = 0;
-        motor_out2  = 0;
-        motor_out3  = 1;
-        wait( 0.2 );
+        motor_out   = 8;
+        wait( 0.2 );        
     }
 }