Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Encoder HIDScope MODSERIAL QEI mbed
Fork of Robobird2 by
main.cpp
- Committer:
 - Fernon
 - Date:
 - 2015-09-28
 - Revision:
 - 7:2042e359bfc3
 - Parent:
 - 6:cf20f04dbab4
 - Child:
 - 8:a2b725b502d8
 
File content as of revision 7:2042e359bfc3:
#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);
Ticker Pot;
double z=0;
void readpot()
{
    z = PotMeter.read()/10;
}
int main()
{
    pc.baud(115200);
    PowerMotor.write(0);
    Pot.attach(readpot,0.1); // Deze ticker moet de waarde uitlezen van de PotMeter 10 keer per seconde
    while (true) {
        pc.printf ("Potmeter = %f\n", z); // het weergeven van de waarde waar z (PotMeter) op dat moment is
        PowerMotor.write(z);
    }
}
            
    