Six crescent shaped legs

Dependencies:   mbed

main.cpp

Committer:
sim642
Date:
2016-03-29
Revision:
3:2235787e78c4
Parent:
2:cf0147952fb9
Child:
4:4d54794b99a5

File content as of revision 3:2235787e78c4:

#include "mbed.h"
#include "EncoderMotor.hpp"
#include "PIDController.hpp"

InterruptIn bt(USER_BUTTON);
Serial pc(USBTX, USBRX);

Encoder e(PA_0, PA_1);
PIDController ec(0.01f);
EncoderMotor m(PB_0, PC_0, PC_1, e, ec);

void rise()
{
    pc.printf("rise\n");
    m.drive(0);
}

void fall()
{
    pc.printf("fall\n");
    m.drive(-380);
}

int main()
{   
    bt.rise(&rise);
    bt.fall(&fall);
    
    m.setup();
    
    while(1)
    {
        pc.printf("%d %d %f\n", e.getCount(), m.getSpeed(), m.out);
        wait(0.1);
    }
}