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: mbed Motordriver
main.cpp
- Committer:
- kociol1994
- Date:
- 2019-03-02
- Revision:
- 0:d080961d29a3
- Child:
- 1:00bee38b3f75
File content as of revision 0:d080961d29a3:
#include "mbed.h"
#include "motordriver.h"
#include "Map.hpp"
float X0, X1, X;
float Y0, Y1, Y;
Motor A(D6, D4, D7, 1); // pwm, fwd, rev, can brake
Motor B(D5, D2, D3, 1); // pwm, fwd, rev, can brake
AnalogIn joy_X(A0);
AnalogIn joy_Y(A1);
Serial pc(SERIAL_TX, SERIAL_RX);
int main() {
while(1){
X0 = joy_X.read();
Y0 = joy_Y.read();
Map(0, 0.5, -1, 0);
Map(0.5, 1, 0, 1);
X = X1;
Map(0, 0.5, -1, 0);
Map(0.5, 1, 0, 1);
Y = Y1;
printf("Pomiar: ");
printf("measure X = %.0f ", X);
printf("measure Y = %.0f \r\n", Y);
wait_ms(50);
if(X0==1) {
A.speed(Y0);
B.speed(Y0);
}else{
A.stop(1);
B.stop(1);
}
/*
wait(1);
A.coast();
B.coast();
*/
}
}