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.
Fork of RoboBirdV1 by
main.cpp
- Committer:
- Fernon
- Date:
- 2015-09-28
- Revision:
- 2:f0e9ffc5df09
- Parent:
- 1:bb11e38dda43
- Child:
- 3:af3f0ed8c99e
File content as of revision 2:f0e9ffc5df09:
#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; const double pi = 3.14159265359; int Pulses; double Rotatie; double z; void readpot (double& z) { z = PotMeter.read(); } int main() { pc.baud(115200); PowerMotor.write(0); Pot.attach(&readpot,&z,0.1); while (true) { Pulses = Encoder.getPulses(); Rotatie = (Pulses*2*pi)/4192; pc.printf ("Potmeter = %f\n", z); pc.printf ("Rotatie = %f [radialen] \n", Rotatie); } }