Engine control program with 3 engines Needs to make a case for each simultaneous engine setting, because of the WAIT after each number of bits have been sent.

Dependencies:   mbed-rtos mbed PinDetect

Fork of FinalMotorControl by Robot Bachelor

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();

    }
}