EMG driven robot which shoots elastic bands

Dependencies:   QEI mbed

Fork of ROBOBIRDS_FINAL by Fernon Eijkhoudt

main.cpp

Committer:
Fernon
Date:
2015-09-23
Revision:
1:bb11e38dda43
Parent:
0:5a5f417fa1b2
Child:
2:f0e9ffc5df09

File content as of revision 1:bb11e38dda43:

#include "mbed.h"
#include "QEI.h"

DigitalOut Direction(D4); //1 = CCW - 0 = CW
PwmOut PowerMotor(D5); //van 0 tot 1
AnalogIn PotMeter(A1);
QEI Encoder(D13,D12,NC,32,QEI::X2_ENCODING); //Encoder
Serial pc(USBTX, USBRX);

double P;
const double pi = 3.14159265359;
int Pulses; 

int main()
{
    while (true) {
        pc.baud(115200);
        for (int n = 0; n < 2; n++) {
            //P = PotMeter.read();
            //pc.printf('P = %f/n', P);
            Pulses = Encoder.getPulses();
            pc.printf ("Pulses = %i", Pulses);
            //  pc.printf ("K = %i \n", K);
            Direction.write(0);
            PowerMotor.write(0.5);
            wait (1);
            Direction.write(1);
            wait (1);
        }
        PowerMotor.write(0);
        return (0);
    }
}