Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 // This program tests how many clock cycles it takes to drive the motor
00003 // one revolution.  in this case it takes 400 clocks.
00004 // i am using a circuit built around a STK672-330 with attached stepper.
00005 
00006 
00007 
00008 
00009 #include "mbed.h"
00010 
00011 DigitalOut enable(5);
00012 DigitalOut direction(6);
00013 DigitalOut clk(7);
00014 int i = 0;
00015 
00016 int main () {
00017 
00018         enable = 1;
00019         direction = 1;
00020         i = 0;
00021             while (i != 40000)   {        // run the motor 100 revolutions, 40 seconds.
00022             
00023                 clk = 1;
00024                 wait_us(500);
00025                 clk = 0;
00026                 wait_us(500);
00027                 
00028                 i += 1;
00029                 }
00030                 
00031         enable = 0;
00032         
00033         }
00034