hfdh

Dependencies:   Encoder MODSERIAL mbed

Fork of BO by Thomas Plaisier

main.cpp

Committer:
lubbermans
Date:
2014-06-30
Revision:
6:7ff223862008
Parent:
5:31120c4c08f0

File content as of revision 6:7ff223862008:

#include "mbed.h"
#include "encoder.h"
#include "MODSERIAL.h"

PwmOut pwmA(PTA1);
PwmOut pwmB(PTD2);
DigitalOut dirA(PTD3);
DigitalOut dirB(PTD1);
Encoder motor1(PTC3,PTB23);
MODSERIAL pc(USBTX,USBRX);
Ticker timer;
Ticker scripttimer;

int x ;
volatile bool scriptflag;

void looper()
{
    pc.printf("%i\n", x);

}
void scripter()
{
    scriptflag=true;
}
int main()
{
    pwmA.period(1.0/20000.0);
    pwmB.period(1.0/20000.0);
    pc.baud(115200);
pc.printf("hoi");
    scripttimer.attach(scripter,1.0/5000.0);
    timer.attach(looper, 0.1);
    while(1) {

        while(scriptflag==false) {
        }
        scriptflag=false;


        x=motor1.getPosition();

        dirA=1;
        pwmA=0.5;


    }
}