han back / Mbed OS CLEO_STEP

main.cpp

Committer:
SMART_CLEO
Date:
2017-09-28
Revision:
0:42d3a9b29f42

File content as of revision 0:42d3a9b29f42:

#include "mbed.h"

// 1A, 1B, 2A, 2B
PinName pin_STEP[4] = {PA_5, PA_6, PA_7, PA_8};

BusOut Step(pin_STEP[0], pin_STEP[1], pin_STEP[2], pin_STEP[3]);

uint8_t Phase_2[4] = {0x03, 0x06, 0x0C, 0x09};

int main()
{
    int count = 0;
    // Step off
    Step = 0;
     
    while(1){
        // CW(360deg)
        for(count = 0; count <= 200; count++)
        {
            Step = Phase_2[count%4];
            wait(0.005);
        }
        Step = 0;
        wait(2);
        // CCW(-360deg)
       for(count = 200; count >= 0; count--)
        {
            Step = Phase_2[count%4];
            wait(0.005);
        }
        Step = 0;
        wait(2);
    }
}